[英]Docker- nginx -Reverse proxy : host not found in upstream when building with docker-compose
我正在使用 NGINX 容器将某些请求重定向到另一个容器。在运行 docker-compose up -d 时,我收到以下错误。
“ 2019/09/26 18:05:00 [emerg] 1#1:在 /etc/nginx/nginx.conf:10 nginx 中的上游“abcplus-visualize:61613”中找不到主机:[emerg] 主机未在/etc/nginx/nginx.conf:10 中的上游“abcplus-visualize:61613 ”
下面是我的 docker-compose.yml 文件
version: '2'
services:
reverseproxy:
image: reverseproxy
ports:
- 49665:2181
restart: always
abcplus-visualize:
depends_on:
- reverseproxy
image: abcplus-visualize:latest
restart: always
下面是我的 nginx.conf 文件
worker_processes 1;
events { worker_connections 1024; }
http {
sendfile on;
upstream docker-abcplus {
server abcplus-visualize:61613;
}
server {
listen 2181;
server_name localhost;
location / {
proxy_pass http://docker-abcplus;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
}
}
}
尝试使用:
upstream docker-abcplus {
server abcplus-visualize:61613 max_fails=6 fail_timeout=30s;
}
我认为您的upstream
在app
运行之前失败得太快了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.