Docker- nginx-反向代理:使用docker-compose进行构建时在上游找不到主机

问题描述 投票:1回答:1

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

2019/09/26 18:05:00 [emerg] 1#1:在/etc/nginx/nginx.conf:10的上游“ abcplus-visualize:61613”中找不到主机nginx:在/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;
        }
    }
}
docker nginx docker-compose nginx-location nginx-reverse-proxy
1个回答
0
投票

尝试使用:

© www.soinside.com 2019 - 2024. All rights reserved.