nginx 配置 nodejs 反向代理

upstream my_nodejs_upstream {
    server 127.0.0.1:3001;
    keepalive 64;
}

server {
    listen 80;
    
    server_name www.my-website.com;
    #ssl_certificate_key /etc/ssl/main.key;
    #ssl_certificate     /etc/ssl/main.crt;
   
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header Host $http_host;
        
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        
        proxy_pass http://my_nodejs_upstream/;
        proxy_redirect off;
        proxy_read_timeout 240s;
    }
}

 

摘自:http://pm2.keymetrics.io/docs/tutorials/pm2-nginx-production-setup

posted @ 2019-10-23 12:28  savokiss  阅读(944)  评论(0编辑  收藏  举报