nginx反向代理nodejs,nginx反向nodejs


nginx version: nginx/1.10.1

 

设置nginx node的反向代理,在/etc/nginx/conf.d/include/nginx.code.conf

然后在etc/nginx/nginx.conf里添加一句include /etc/nginx/conf.d/include/*;

 

nginx.code.conf内容:(include/nginx.code.conf为需要自己建立的文件)

 

upstream nodejs {

#只需要修改此处的3000端口,改为自己应用的端口

server 127.0.0.1:3000;

#server 127.0.0.1:3001; 

    keepalive 64;

}

 

server {

#80nginx代理的端口,如果修改还需要改其他配置信息

    listen 80;

    server_name localhost;

    access_log /var/log/nginx/test.log;

    location / {

        proxy_set_header X-Real-IP $remote_addr;

        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        proxy_set_header Host  $http_host;

        proxy_set_header X-Nginx-Proxy true;

        proxy_set_header Connection "";

        proxy_pass      http://nodejs;

 

    }

 

}

 


etc/nginx/nginx.conf内容:


 

相关内容

    暂无相关文章