求ubuntu Nginx反向代理到127.0.0.1:3000配置,我的配置没成功,求连接!!!
发布于 10 年前 作者 jintaolee 13042 次浏览 最后一次编辑是 8 年前
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;
    }
 }

讨教个问题,打开http://www.yooteam.net打不开 但是打开http://www.yooteam.net:80能到nginx初始页面还是没打开我的项目 求指教!

应该可以吧,试试 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; }

}

目测要nginx -s reload

回到顶部