Rewrite header Location from HTTP to HTTPS

Viewed 393

Nginx adds a Location header in its reply. This one is in HTTP. I would like to replace it by HTTPS.

I tried with proxy_redirect.

With the hard URL, it works:

proxy_redirect http://www.mywebsite.com/fr/connexion?toUrl=%2Ffr https://www.mywebsite.com/fr/connexion?toUrl=%2Ffr;

However, I can't integrate RegEx in the command to make it work every time.

Do you have an idea?

1 Answers

As Richard Smith said, it is not necessary to use a REGEX. Simply fill in the following directive:

proxy_redirect http:// https://;

or

proxy_redirect http://www.yourwebsite.com/ https://www.yourwebsite.com/;

Credit to Richard Smith for the answer

Related