Advertisement
Guest User

Untitled

a guest
Sep 5th, 2015
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. container_commands:
  2. 01_fix_static_cors:
  3. command: "/tmp/fix_static_cors.sh"
  4. files:
  5. "/tmp/fix_static_cors.sh":
  6. mode: "000755"
  7. owner: root
  8. group: root
  9. content: |
  10. #!/bin/bash
  11. pushd $(/opt/elasticbeanstalk/bin/get-config container -k config_staging_dir)
  12. echo "Adding CORS Config"
  13. PROXY_CONF="#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf"
  14. grep static_cors.config $PROXY_CONF || sed -i '/location \/static {/a \ \ \ \ include /etc/nginx/conf.d/static_cors.config;' $PROXY_CONF
  15. "/etc/nginx/conf.d/static_cors.config":
  16. mode: "000644"
  17. owner: root
  18. group: root
  19. content: |
  20. #
  21. # Wide-open CORS config for nginx
  22. #
  23. if ($request_method = 'OPTIONS') {
  24. add_header 'Access-Control-Allow-Origin' '*';
  25. #
  26. # Om nom nom cookies
  27. #
  28. add_header 'Access-Control-Allow-Credentials' 'true';
  29. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  30. #
  31. # Custom headers and headers various browsers *should* be OK with but aren't
  32. #
  33. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  34. #
  35. # Tell client that this pre-flight info is valid for 20 days
  36. #
  37. add_header 'Access-Control-Max-Age' 1728000;
  38. add_header 'Content-Type' 'text/plain charset=UTF-8';
  39. add_header 'Content-Length' 0;
  40. return 204;
  41. }
  42. if ($request_method = 'POST') {
  43. add_header 'Access-Control-Allow-Origin' '*';
  44. add_header 'Access-Control-Allow-Credentials' 'true';
  45. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  46. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  47. }
  48. if ($request_method = 'GET') {
  49. add_header 'Access-Control-Allow-Origin' '*';
  50. add_header 'Access-Control-Allow-Credentials' 'true';
  51. add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
  52. add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement