I am trying to redirect http://example.com , https://example.com , http://www.example.com to https://www.example.com . Servers listening to both http and https requests via 443 port through ELB.
nginx config :
server {
listen 443;
server_name example.com;
return 301 $scheme://www.example.com$request_uri;
}
server {
listen 443 default;
server_name www.example.com;
//ssl stuffs
}
only http://example.com and https://www.example.com is working as expected.But http://www.example.com is going to infinite redirection loop.
What might be wrong with the config file. Any help would be appreciated.