Skip to content

Instantly share code, notes, and snippets.

@solastley
Last active June 28, 2018 05:37
Show Gist options
  • Save solastley/6ed955eda29754a72d892eeaf8b04c6b to your computer and use it in GitHub Desktop.
Save solastley/6ed955eda29754a72d892eeaf8b04c6b to your computer and use it in GitHub Desktop.
files:
"/home/ec2-user/setup.sh":
mode: "000755"
owner: root
group: root
content: |
#!/bin/bash
# access AWS environment variables
source /opt/python/current/env
if [ "$PROD" = "True" ]
then
# create Apache configuration file
cat <<EOT > /etc/httpd/conf.d/ssl_rewrite.conf
# force HTTP traffic to HTTPS
RewriteEngine On
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>
EOT
# set appropriate permissions
chown root:root /etc/httpd/conf.d/ssl_rewrite.conf
chmod 000755 /etc/httpd/conf.d/ssl_rewrite.conf
fi
container_commands:
set_up:
command: /home/ec2-user/setup.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment