Aliyun uses node.js + nginx to build a website, and every visit is' welcom to nginx''.

problem description:
I use node.js + nginx to build a personal website on Aliyun, but every visit is a "welcom to nginx" prompt

  1. server.js file
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");

run this file with pm2 and start successfully:

  1. configuration of nginx
There is a web.conf file under the file of

conf/servers

server {
  listen       80;
  server_name  tonghuiflang.com;

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

add include servers/*; at the end of the http of conf/nginx.conf and conf/nginx.conf.default

but access through the domain name or "welcom to nginx" prompt, there is no problem locally

Mar.25,2021

did you restart nginx after updating the configuration?


your nginx reverse proxy is 127.0.0.1, your server listening is 0.0.0.0, so change it to 127.0.0.1


solved. I downloaded the configuration files of two versions of the nginx, application before in the / etc/nginx/conf.d folder. Thank you

.
Menu