node.js应用程序在端口80上运行良好(使用pm2和nginx),并且可以很好地浏览服务器IP。但是通过域,它无法正常工作(无法联系此站点)。在pinging域时,可以在响应上看到服务器IP。
这是我使用的nginx配置:
location / {
proxy_pass "http://127.0.0.1:8000";
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
您需要在nginx配置中使用 server_name
声明。
server_name example.org www.example.org;
http://nginx.org/en/docs/http/server_names.html