如何重新導向 nginx 代理程式?

如何重新導向 nginx 代理程式?

我正在運行 2 個 geoserver 和 nginx 容器。我想打電話https://xxx.xxx.com/geoserver另一個https://xxx.xxx.com/geoserver2。地理伺服器容器在代理容器後面運行。這是預設的domain.com/geoserver 配置。


location /geoserver {
add_header           Front-End-Https    on;
add_header  Cache-Control "public, must-revalidate";
add_header Strict-Transport-Security "max-age=2592000; includeSubdomains";
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://geoserver_geoserver_1:8080/geoserver;
}

我如何呼叫domain.com/geoserver2 我正在嘗試一些配置,但是當我嘗試登入時,網域重定向geoserver_geoserver_1這個容器。但geoserver2應該要執行geoserver_geoserver_2這個容器。

location /geoserver2/ {
    add_header           Front-End-Https    on;
    add_header  Cache-Control "public, must-revalidate";
    add_header Strict-Transport-Security "max-age=2592000; includeSubdomains";
    proxy_set_header Host $http_host;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header X-Forwarded_For $proxy_add_x_forwarded_for;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://geoserver_geoserver_2:8080/geoserver/;
    proxy_redirect   /geoserver /geoserver2;
}

相關內容