[英]What nginx server config exactly should be for Nuxt.js Universal project?
I've got big troubles with deploy my nuxt.js project on Ubuntu with Nginx; 使用Nginx在Ubuntu上部署我的nuxt.js项目时遇到了很多麻烦;
Ubuntu 18.04 + nginx
Nuxt.js 2.3.2 (universal mode)
So maybe somebody can help me to resolve my problem) 所以也许有人可以帮助我解决我的问题)
I will to describe all things around this problem below: 我将在下面描述有关此问题的所有事情:
My nuxt.conf build part 我的nuxt.conf构建部分
Then I run this command in ssh 然后我在ssh中运行此命令
sudo npm run build
sudo pm2 start npm --name "nuxt" -- start
Now server is listening localhost:3000, as I wrote in package.json 现在服务器正在监听localhost:3000,就像我在package.json中写的那样
After all this I've got 500 error in console, when I open my site. 毕竟,打开网站后,控制台中出现500错误。 Server error
服务器错误
nginx error.log 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"
So now I have no idea whats wrong with that. 所以现在我不知道这是怎么了。 Help me please.
请帮帮我。
It seems that Nginx tries to connect on the IPv6 loopback [::1], and nodejs is probably just listening on IPv4. 似乎Nginx尝试在IPv6环回[:: 1]上进行连接,而nodejs可能只是在侦听IPv4。
Try setting 127.0.0.1
instead of localhost
尝试设置
127.0.0.1
而不是localhost
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.