【发布时间】:2020-05-24 12:04:21
【问题描述】:
我有一个 nginx 服务器,在“localhost/api”上有一个 nodejs API,在“localhost/”上有一个 PGAdmin4。在这种情况下,一切正常,但是一旦我在“localhost/pgadmin4”上的 nginx.conf 中配置 PGAdmin4 的位置,当我单击 PGAdmin4 界面上的登录按钮时,我就会被重定向到“localhost/”因此不要访问 PGAdmin。
我尝试了这里找到的几种解决方案,但没有任何效果..
这是我的 nginx.conf 文件(proxy_pass 中的 pgadmin 在我的 docker-compose.yml 中定义):
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /dev/null;
upstream app {
least_conn;
server app:3000 weight=10 max_fails=3 fail_timeout=30s;
}
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
location /api/ {
proxy_pass http://app;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /pgadmin {
proxy_pass http://pgadmin;
proxy_http_version 1.1;
proxy_set_header X-Script-Name /pgadmin;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
}
【问题讨论】:
标签: postgresql nginx pgadmin