I have an account in Jelastic and I want to force my site to work only over https. I've created environment nginx + php with nginx balancer and enabled Jelastic SSL (as it described here).
Whenever I tried to setup 301 redirect from http to https with no luck. Using mod_rewrite didn't work for me, the only thing I've got is a loop redirect. Google didn't help.
I really need advise. Any additional info will be provided.
Thanks in advance.
The accepted solution did not work for my setup. I had to change the if statement to the following:
if ($http_x_forwarded_proto != "https") {
return 301 https://$host$request_uri;
}
As described in the official nginx documentation https://www.nginx.com/blog/creating-nginx-rewrite-rules#https you should use:
return 301 https://$host$request_uri;
which works as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With