4 回复
给一个完整示例
#Node Express Staging on Port 3000
upstream appname{
server 127.0.0.1:3000;
}
# NGINX Server Instance,PORT 80
server {
listen 0.0.0.0:80;
server_name appname.domain;
access_log /var/log/nginx/appname;
# Gzip Compression
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
# Proxy to the Node instance
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_pass http://localhost:3000;
proxy_redirect off;
}
}
应该可以吧,试试 server { listen 80; server_name appname.domain; location / { proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:3000; }
}