gpt4 book ai didi

Docker-nginx-反向代理: host not found in upstream when building with docker-compose

转载 作者:行者123 更新时间:2023-12-02 04:22:54 34 4
gpt4 key购买 nike

我正在使用 NGINX 容器将某些请求重定向到另一个容器。在运行 docker-compose up -d 时,出现以下错误。

"2019/09/26 18:05:00 [emerg] 1#1:在/etc/nginx/nginx.conf:10 的上游“abcplus-visualize:61613”中找不到主机 nginx:[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;
}

我认为在 app 运行之前你的 upstream 失败得太快了

关于Docker-nginx-反向代理: host not found in upstream when building with docker-compose,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58122870/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com