【发布时间】:2021-05-07 10:49:34
【问题描述】:
我已经在 StackOverflow 上搜索了我的问题,但我似乎总是使用我的 Nginx Docker 配置访问502 Bad Gateway。我正在尝试使用我的域mydomain.com/pgadmin 而不是mydomain.com:8060 访问pgadmin4,其中8060 是它的docker 容器公开的端口。我的docker-compose.yml 文件如下所示:
version: '3.5'
services:
reverse-proxy:
image: nginx:1.19.6
restart: always
ports:
- "80:80"
- "443:443"
postgres:
image: postgres:12
ports:
- "5432:5432"
pgadmin:
image: dpage/pgadmin4
depends_on:
- postgres
ports:
- "8060:80"
networks:
default:
external:
name: defaultnetwork
我的 nginx 容器的default.conf 文件如下所示:
upstream pgadmin {
server 127.0.0.1:8060;
}
server {
listen 80;
listen [::]:80;
server_name mydomain.com;
root /usr/share/nginx/html;
index index.html index.htm;
location /pgadmin {
proxy_pass http://pgadmin;
}
}
使用此配置,我不断收到502 Bad Gateway 错误。有人可以指出我哪里出错了。我真的很感激。
谢谢。
[编辑] 这是来自 docker 日志:
2021/02/03 08:07:42 [error] 23#23: *2 connect() failed (111: Connection refused) while connecting to upstream, client: ***.***.***.***, server: mydomain.com, request: "GET /pgadmin HTTP/1.1", upstream: "http://127.0.0.1:8082/pgadmin", host: "mydomain.com"
【问题讨论】:
标签: docker nginx docker-compose nginx-reverse-proxy