Created
April 10, 2018 22:32
-
-
Save nuxero/f8a30877c520c6792b26ff838ed15279 to your computer and use it in GitHub Desktop.
Force https using ebextensions
This file contains hidden or 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: | |
"/tmp/nginx_https_rw.sh": | |
owner: root | |
group: root | |
mode: "000644" | |
content: | | |
#! /bin/bash | |
CONFIGURED=`grep -c "return 301 https" /etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy.conf` | |
if [ $CONFIGURED = 0 ] | |
then | |
sed -i '/listen 80;/a \ if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; }\n' /etc/nginx/sites-available/elasticbeanstalk-nginx-docker-proxy.conf | |
logger -t nginx_rw "https rewrite rules added" | |
exit 0 | |
else | |
logger -t nginx_rw "https rewrite rules already set" | |
exit 0 | |
fi | |
"/etc/nginx/conf.d/maxfilesize.conf": | |
owner: root | |
group: root | |
mode: "000644" | |
content: | | |
client_max_body_size 50M; | |
container_commands: | |
00_rewrite_script_perms: | |
command: chmod 755 /tmp/nginx_https_rw.sh | |
01_run_script: | |
command: /tmp/nginx_https_rw.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment