So here is my config:
server {
listen 80;
server_name *.example.com;
if ($http_x_forwarded_proto = 'http') {
return 301 https://$server_name$request_uri;
}
}
When I go to example.com nginx redirect me to https://example.com but the page is a stub nginx index.html. If I go www.example.com it stays unsecure so it is not redirected at all.
What I am doing wrong? Thanks.
EDIT: When I do like in this article: https://aws.amazon.com/premiumsupport/knowledge-center/redirect-http-https-elb/
return 301 https://$server_name$request_uri$http_x_forwarded_proto;
Then it is redirected https://example.com/http And of course it is 404 cause http endpoint is stupid.