Last active
April 9, 2021 06:52
-
-
Save edhowler/518381ff4a340045317af1657b1de24c to your computer and use it in GitHub Desktop.
Elastic Beanstalk configuration to redirect HTTP to HTTPS (place this inside .ebextensions folder and deploy)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
files: | |
/etc/nginx/conf.d/elasticbeanstalk/00_application2.conf: | |
owner: root | |
group: root | |
mode: "000644" | |
content: | | |
location / { | |
set $redirect 0; | |
if ($http_x_forwarded_proto != "https") { | |
set $redirect 1; | |
} | |
if ($http_user_agent ~* "ELB-HealthChecker") { | |
set $redirect 0; | |
} | |
if ($redirect = 1) { | |
return 301 https://$host$request_uri; | |
} | |
proxy_pass http://127.0.0.1:8000; | |
proxy_http_version 1.1; | |
proxy_set_header Connection $connection_upgrade; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
container_commands: | |
removeconfig: | |
command: "sudo rm -f /etc/nginx/conf.d/elasticbeanstalk/00_application.conf" | |
nginx_reload: | |
command: "sudo service nginx reload" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment