我有一个nginx服务器,它在'localhost/ API‘上有一个nodejs,在'localhost/’上有一个PGAdmin4。在这种情况下,所有操作都没有问题,但是一旦我在‘localhost/ PGAdmin 4’上配置了PGAdmin4在nginx.conf中的位置,当我单击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;
}
}
}
发布于 2020-05-24 14:47:36
使用apache24作为反向代理,pgadmin4使用uWSGI独立运行,我成功地在反向代理中设置了X-Script-Name
头。
或者,它还可以正常工作,不设置反向代理中的X-Script-Name
头,也不重写反向代理中的URL路径组件,而是将以下配置添加到uWSGI中:
route-run = addvar:SCRIPT_NAME=/pgadmin
route = ^/pgadmin(.*) rewrite:$1
这将从PATH_INFO
中移除重新定位URL路径组件,并将其放入SCRIPT_NAME
中,并且与所使用的used服务器无关。
我不熟悉nginx,但是将引用的配置与https://www.pgadmin.org/docs/pgadmin4/latest/container_deployment.html#http-via-nginx的文档进行比较,我可能会认为您的proxy_path值是错误的,应该包含类似于http://localhost:5050/
的内容。
https://stackoverflow.com/questions/61985683
复制相似问题