Nginx 位置 - 更改位置后站点配置不起作用

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

我在 ubuntu 服务器上设置了 pgadmin,nginxconf 如下所示并且工作正常,example.com/:

server {
    ...

    location / {
        proxy_pass http://unix:/tmp/pgadmin4.sock;
        include proxy_params;
    }

}

但是我想使用 /pgadmin4/ 访问 pgadmin,并且我将块服务器更改为下面但不起作用,example.com/pgadmin4/:

server {
    ...
    location /pgadmin4/ {
        proxy_pass http://unix:/tmp/pgadmin4.sock;
        include proxy_params;
    }

}
nginx pgadmin-4
1个回答
0
投票

我已将此行添加到位置 /pgadmin 并且工作正常:

location /pgadmin {
    proxy_pass http://unix:/tmp/pgadmin4.sock;
    include proxy_params;
    proxy_redirect http:// $scheme://;
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Script-Name /pgadmin;
}
© www.soinside.com 2019 - 2024. All rights reserved.