I have the following scenario:
NGINX | | JavaEE
TERMINATING | -> REVERSE PROXY -> | Application
SSL (443) | HTTP | Server
Reverse proxy is done by:
location /app/ {
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Host www.example.com;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header REMOTE_ADDR $remote_addr;
proxy_pass http://192.168.0.10:8080/app/;
}
The problem was that, all relative redirects done at application server (i.e. Location: /app/login) where being redirected to http://www.example.com/app/login
instead of its https counterpart https://www.example.com/app/login
.
So, to fix it, I added this to NGINX's location configuration:
proxy_redirect http://www.example.com/ https://www.example.com/;
And it started working without issues.
My question is: is it good practice to have such a redirect? Is there another way of doing this?
0 Answers