amazon web services - Elastic beanstalk nginx redirect setting not working -
i'm trying redirect http https , have config:
files: "/etc/nginx/conf.d/robots.conf": mode: "000544" owner: root group: root content: | server { listen 80; server_name example.com; location =/health { return 200 "health-check"; } location / { if ($http_x_forwarded_proto != "https") { return 301 https://$host$request_uri; } } } server { listen 80 default_server; server_name www.example.com; location =/health { return 200 "health-check"; } location / { if ($http_x_forwarded_proto != "https") { return 301 https://$host$request_uri; } } } but when go http://example.com or http://www.example.com there no redirect... i've tried multiple settings seems never works.
the best way set config below
server { listen 80; server_name my.example.com; return 301 https://$server_name$request_uri; } server { listen 443 ssl; server_name my.example.com; # add strict-transport-security prevent man in middle attacks add_header strict-transport-security "max-age=31536000"; [....] }
Comments
Post a Comment