-
-
Save rubyisbeautiful/796eb149771bb987ca9b38e2c89a528b to your computer and use it in GitHub Desktop.
Add CORS to Nginx on AWS Elastic Beanstalk
This file contains 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
# This doesn't quite work, and neither do any of the others I found. | |
# At EB deploy time, it generates the config found in /tmp/passenger-standalone* from a template | |
# | |
container_commands: | |
01_fix_static_cors: | |
command: "/tmp/fix_static_cors.sh" | |
files: | |
"/tmp/fix_static_cors.sh": | |
mode: "000755" | |
owner: root | |
group: root | |
content: | | |
#!/bin/bash -ex | |
support_dir=$(/opt/elasticbeanstalk/bin/get-config container -k support_dir) | |
echo "Adding CORS Config" | |
proxy_template_a="$support_dir/conf/nginx_config.erb" | |
proxy_template_b="$support_dir/conf/nginx_config_healthd.erb" | |
grep Access-Control-Allow $proxy_template_a || sed -i '/location @static_asset {/a \ \ \ \ \ \ \ \ \ \ \ \ add_header 'Access-Control-Allow-Origin' '*';' $proxy_template_a | |
grep Access-Control-Allow $proxy_template_b || sed -i '/location @static_asset {/a \ \ \ \ \ \ \ \ \ \ \ \ add_header 'Access-Control-Allow-Origin' '*';' $proxy_template_b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment