[英]nginx & nodejs: connect() failed (111: Connection refused) while connecting to upstream
[英]vue / nodejs & nginx in docker: connect() failed (111: Connection refused) while connecting to upstream
目录结构:
myapp
-- frontend
---- docker
------ frontend
-------- nginx
-------- nginx.conf
docker-compose.yml
docker-compose.yml: https ://pastebin.com/THxMf0xM(移至 pastebin 以避免烦人的“主要是代码”错误)
默认.conf:
server {
listen 80;
server_name localhost;
root /var/www/html;
location / {
proxy_pass http://vue:8081;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
为什么connect() failed (111: Connection refused) while connecting to upstream
?
https://pastebin.com/THxMf0xM
第 23 行,应该指向端口 80,即ports: - '8081:80'
通过更改proxy_pass http://vue:8081;
修复proxy_pass http://vue:8081;
到proxy_pass http://vue:8080;
注意8080端口。
其次,重建前端服务
最后,从 vue 服务中删除ports
选项
谢谢你们
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.