配置nigx反向代理的问题
用pm2将nodejs部署在了Centos7上,现在访问192.168.1.11:3000可以访问网站,也安装了nigx,请问怎么配置nigx才能让电脑访问 “www.xxxx.com”就能链接到我的node工程呢? 网上有一些例子,但是请教个详细的方式,最好有配置代码
10 回复
@alsotang 配置方式如下“ upstream my_nodejs_upstream { server 127.0.0.1:3000; }
server { listen 80; server_name my_nodejs_server; root /home/www/project_root;
location / {
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_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_max_temp_file_size 0;
proxy_pass http://my_nodejs_upstream/;
proxy_redirect off;
proxy_read_timeout 240s;
}
}
怎么访问呢?