鍍金池/ 問(wèn)答/Python  HTML/ 阿里云上面用node.js + nginx搭建網(wǎng)站,每次訪問(wèn)都是‘welcom

阿里云上面用node.js + nginx搭建網(wǎng)站,每次訪問(wèn)都是‘welcom to nginx’提

問(wèn)題描述:
我在阿里云上面用node.js + nginx搭建一個(gè)個(gè)人網(wǎng)站,但是每次訪問(wèn)都是‘welcom to nginx’提示

  1. server.js文件
http.createServer(function(req, res){
   const pathname = url.parse(req.url).pathname;
   console.log(pathname);

   switch(pathname){
       case '':
       case '/':
         index(req, res);break;
       default:
         loadfiels(req, res, pathname);break;
   }
}).listen(9000, '0.0.0.0');

用pm2運(yùn)行這個(gè)文件,啟動(dòng)成功了:
圖片描述

  1. nginx 的配置

conf/servers的文件下面有一個(gè)web.conf文件

server {
  listen       80;
  server_name  tonghuiflang.com;

  location / {
      proxy_pass http://127.0.0.1:9000;
  }
}

在conf/nginx.conf 和 conf/nginx.conf.default 的http最后 添加 include servers/*;

可是通過(guò)域名訪問(wèn)還是‘welcom to nginx’提示,在本地是沒(méi)有問(wèn)題的

回答
編輯回答
愛(ài)是癌

你nginx反向代理的是127.0.0.1,你server監(jiān)聽(tīng)的是0.0.0.0,要改成127.0.0.1吧

2017年5月11日 12:28
編輯回答
汐顏

更新配置后重啟 nginx 了嗎?

2018年7月16日 05:05
編輯回答
薄荷糖

解決了,我之前下載了兩個(gè)版本的nginx,應(yīng)用的配置文件在/etc/nginx/conf.d的文件夾下,謝謝大伙了

2018年1月23日 13:31