Skip to content

Instantly share code, notes, and snippets.

@ebarault
Forked from miguelmota/setup.config
Created March 7, 2018 09:15
Show Gist options
  • Save ebarault/88b7b9704d6a30d2f55e98f78a21f4dd to your computer and use it in GitHub Desktop.
Save ebarault/88b7b9704d6a30d2f55e98f78a21f4dd to your computer and use it in GitHub Desktop.
Elastic Beanstalk NGINX rewrite http to https using .ebextensions
files:
"/etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf":
mode: "000755"
owner: root
group: root
content: |
server {
listen 80;
gzip on;
if ($http_x_forwarded_proto != 'https') {
rewrite ^(.*) https://$host$1 redirect;
}
location / {
proxy_pass http://docker;
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;
}
}
@ebarault
Copy link
Author

ebarault commented Mar 7, 2018

  1. place this in the .ebextensions folder and zip this folder with your Dockerrun.aws.json
    NOTE: Dockerrun.aws.json and .ebextensions folder should be at the root of the zip archive

  2. add the following lines to your eb_config.yml file:

deploy:
  artifact: path/to/file.zip
...
  1. run eb deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment