Skip to content

Instantly share code, notes, and snippets.

@matthewberryman
Created February 13, 2017 11:10
Show Gist options
  • Save matthewberryman/095e4aa8c8c3260c028ef6d1351d7f4d to your computer and use it in GitHub Desktop.
Save matthewberryman/095e4aa8c8c3260c028ef6d1351d7f4d to your computer and use it in GitHub Desktop.
config file for adding basic auth to an elastic beanstalk nginx config
files:
/etc/nginx/.htpasswd:
mode: "000644"
owner: root
group: root
content: |
username:passwd_hash
# use httpasswd -c -b password_file desired_username desired_password
# and copy and paste the line from that in to username:password_hash
/tmp/deployment/nginx_auth.sh:
mode: "000755"
content: |
sed -i 's/$proxy_add_x_forwarded_for;/$proxy_add_x_forwarded_for;\n auth_basic "Restricted";\n auth_basic_user_file \/etc\/nginx\/.htpasswd;\n/' "/tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf"
sudo cp /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
sudo /sbin/service nginx restart
exit 0
container_commands:
01nginx_auth:
command: "sudo /tmp/deployment/nginx_auth.sh"
@rainer-maucher
Copy link

HAs anyone an working update for this script? I cant make it work for an python 3.7 instance :/

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