我无法获得 PGAdmin 的 Nginx 反向代理。当没有从主机系统加载配置文件时,Nginx 似乎使用默认配置。 PGAdmin 正在工作。
这是我的 nginx 配置文件
upstream docker-pgadmin {
server pgadmin:80;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name _;
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/key.pem;
ssl_protocols TLSv1.2;
charset utf-8;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log crit;
location / {
proxy_pass http://docker-pgadmin;
proxy_buffering off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
}
}
这是我的 docker compose yaml
version: '3.8'
networks:
pgadminNet:
driver: bridge
services:
pgadmin-nginx:
container_name: nginx
image: nginx
restart: on-failure
volumes:
- ./sites_config/:/etc/nginx/conf.d/
- ./ssl/:/etc/ssl/
- ./log/:/var/log/nginx/
ports:
- "80:80"
- "443:443"
networks:
- pgadminNet
pgadmin:
container_name: pgadmin
image: dpage/pgadmin4
restart: on-failure
depends_on:
- pgadmin-nginx
environment:
PGADMIN_DEFAULT_EMAIL: <login email>
PGADMIN_DEFAULT_PASSWORD: <login email password>
PGADMIN_DISABLE_POSTFIX: True
PGADMIN_LISTEN_ADDRESS: 0.0.0.0
PGADMIN_SERVER_JSON_FILE: /pgadmin4/servers.json
volumes:
- ./storage:/var/lib/pgadmin
networks:
- pgadminNet
我已准备好所有必需的目录和文件。我收到以下错误,没有更多详细信息(来自 Nginx 日志)。
2023/05/18 10:36:29 [notice] 1#1: signal 29 (SIGIO) received
2023/05/18 10:36:29 [notice] 1#1: signal 17 (SIGCHLD) received from 27
2023/05/18 10:36:29 [notice] 1#1: signal 17 (SIGCHLD) received from 31
2023/05/18 10:36:29 [notice] 1#1: worker process 22 exited with code 0
2023/05/18 10:36:29 [notice] 1#1: worker process 31 exited with code 0
2023/05/18 10:36:29 [notice] 1#1: worker process 32 exited with code 0
2023/05/18 10:36:29 [notice] 1#1: exit
我已经测试了配置文件
docker exec -it nginx nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
我迷路了
/etc/nginx/nginx.conf 有一行 include /etc/nginx/conf.d/*.conf;我的配置仅命名为 pgadmin。将我的配置重命名为 pgadmin.conf 有效。