0
我有Tomcat 6在路徑「be」上運行web應用程序。 Spring安全性用於登錄過程。登錄網址爲/console/login
,登錄後重定向至/console/customer
。我使用https爲login
url和http爲customer
URL。我沒有在任何spring配置文件中指定servlet路徑。所有工作正常,訪問/be/console/login
後正確的重定向(至)收到。nginx代理添加servlet路徑
現在我想要一個代理。我配置Nginx轉發https://localhost
到https://<someip>:9443
和http相同,從端口80轉發到端口9080.
問題是,Nginx正在返回無效的重定向到瀏覽器。相反它返回/be/be/console/customer
。 Servlet路徑被添加到URL兩次。
那第二個'be'怎麼可能被刪除?
謝謝。
Nginx的配置:
server {
listen 443 ssl;
server_name localhost;
ssl on;
ssl_certificate C:\jc\\nginx\\tc\selfsigned.cer;
ssl_certificate_key C:\jc\\nginx\\tc\private.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location/{
proxy_redirect off;
proxy_pass https://<some ip>:9443;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
location ~ /.+ {
proxy_redirect off;
proxy_pass https://<some ip>:9443;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
server {
listen 80;
server_name localhost;
access_log logs/access.log;
error_log logs/error.log;
location/{
proxy_redirect off;
#server_name_in_redirect off;
proxy_pass http://<some ip>:9080;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
location ~ /.+ {
proxy_redirect off;
proxy_pass http://<some ip>:9080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
}
}
proxy_pass_request_headers是在默認情況下,其餘的(不同的特性參數的)只是性能相關的配置。所以這個問題要複雜得多。 – Dima