Nginx
Jetty 9 上的 https 到 http 反向代理
好的,所以基本上我想做的是設置一個反向代理來在 nginx 上提供 https 頁面,並使用 http 將它們重定向到 Jetty。問題是 servlet 實際上需要 https 並在看到它被發送到 http 頁面後重定向到 https 地址。
以前我通過添加以下內容在 Jetty 7 下執行它:
<Set name="forwarded">true</Set>
到 SelectChannelConnector 的 jetty.xml ,現在我決定升級到 Jetty 9 我似乎找不到任何替代這個配置的東西,我很確定我的 nginx 設置沒有問題,因為它曾經與 Jetty 完美配合7.
這是我的 nginx 配置的一部分,只是為了讓事情更清楚我在那裡得到了什麼:
location / { proxy_pass http://127.0.0.1:8080; include /etc/nginx/proxy_params; }
雖然這是我的 proxy_params 文件:
proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;
這似乎是一件相當簡單的事情。只需取消註釋以下部分
/etc/jetty.xml
:<!-- Uncomment to enable handling of X-Forwarded- style headers <Call name="addCustomizer"> <Arg><New class="org.eclipse.jetty.server.ForwardedRequestCustomizer"/></Arg> </Call> -->
所以我要麼是盲人,要麼是舊版本的 Jetty 9 在如此明顯的地方沒有這個選項。