使用Nginx在Ubuntu上部署nuxt.js项目时遇到了很多麻烦;
Ubuntu 18.04 + nginx
Nuxt.js 2.3.2 (universal mode)
所以也许有人可以帮助我解决我的问题)
我将在下面描述有关此问题的所有事情:
然后我在ssh中运行此命令
sudo npm run build
sudo pm2 start npm --name "nuxt" -- start
现在服务器正在监听localhost:3000,就像我在package.json中写的那样
所有这些之后,当我打开网站时,控制台出现500错误。 Server error
nginx error.log
2018/11/26 04:48:42 [error] 15032#15032: *5773 upstream prematurely closed connection while reading response header from upstream, client: 173.267.244.9, server: example.com, request: "GET /seller HTTP/1.1", upstream: "http://127.0.0.1:3000/seller", host: "example.com"
2018/11/26 04:48:42 [error] 15032#15032: *5773 connect() failed (111: Connection refused) while connecting to upstream, client: 173.267.244.9, server: example.com, request: "GET /seller HTTP/1.1", upstream: "http://[::1]:3000/seller", host: "example.com"
2018/11/26 04:48:43 [error] 15032#15032: *5773 no live upstreams while connecting to upstream, client: 173.267.244.9, server: example.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "example.com", referrer: "http://example.com/seller"
所以现在我不知道这有什么问题。请帮帮我。
答案 0 :(得分:0)
似乎Nginx尝试通过IPv6环回[:: 1]进行连接,而nodejs可能只是在侦听IPv4。
尝试设置127.0.0.1
而不是localhost