river-of-ebooks/.ebextensions/03_nginx_proxy.config

49 lines
1.7 KiB
Plaintext
Raw Normal View History

2019-04-16 17:37:52 +00:00
files:
2019-04-16 17:57:31 +00:00
"/tmp/45_nginx_https_rw.sh":
2019-04-16 17:37:52 +00:00
owner: root
group: root
2019-04-16 17:57:31 +00:00
mode: "000644"
2019-04-16 17:37:52 +00:00
content: |
2019-04-16 17:57:31 +00:00
#! /bin/bash
2019-04-16 17:37:52 +00:00
2019-04-16 17:57:31 +00:00
CONFIGURED=`grep -c "return 301 https" /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf`
2019-04-16 17:37:52 +00:00
2019-04-16 17:57:31 +00:00
if [ $CONFIGURED = 0 ]
then
sed -i '/listen 8080;/a \ if ($http_x_forwarded_proto = "http") { return 301 https://$host$request_uri; }\n' /etc/nginx/conf.d/00_elastic_beanstalk_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
2019-04-16 17:37:52 +00:00
2019-04-23 20:25:45 +00:00
/opt/elasticbeanstalk/hooks/configdeploy/post/99_kill_default_nginx.sh:
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash -xe
rm -f /etc/nginx/conf.d/00_elastic_beanstalk_proxy.conf
status=`/sbin/status nginx`
if [[ $status = *"start/running"* ]]; then
echo "stopping nginx..."
stop nginx
echo "starting nginx..."
start nginx
else
echo "nginx is not running... starting it..."
start nginx
fi
2019-04-16 17:37:52 +00:00
container_commands:
2019-04-16 17:57:31 +00:00
00_appdeploy_rewrite_hook:
command: cp -v /tmp/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/appdeploy/enact
01_configdeploy_rewrite_hook:
command: cp -v /tmp/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact
02_rewrite_hook_perms:
command: chmod 755 /opt/elasticbeanstalk/hooks/appdeploy/enact/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact/45_nginx_https_rw.sh
03_rewrite_hook_ownership:
command: chown root:users /opt/elasticbeanstalk/hooks/appdeploy/enact/45_nginx_https_rw.sh /opt/elasticbeanstalk/hooks/configdeploy/enact/45_nginx_https_rw.sh