|
| 1 | +server { |
| 2 | + server_name {{ CURRENT_HOST }}; |
| 3 | + |
| 4 | + {%-if ENV == "VAGRANT" %} |
| 5 | + listen 80; |
| 6 | + {%- else %} |
| 7 | + listen 443 ssl; |
| 8 | + {%- endif %} |
| 9 | + |
| 10 | + {%-if ENV == "VAGRANT" %} |
| 11 | + {# Do not use certificates on vagrant installation #} |
| 12 | + {%- else %} |
| 13 | + ssl_certificate /etc/ssl/certs/www.steepshot.io.certchain.crt; |
| 14 | + ssl_certificate_key /etc/ssl/private/steepshot.io.key; |
| 15 | + {%- endif %} |
| 16 | + |
| 17 | + access_log {{ DEPLOY_DIR }}/logs/nginx-access.log; |
| 18 | + error_log {{ DEPLOY_DIR }}/logs/nginx-error.log; |
| 19 | + |
| 20 | + client_max_body_size 10M; |
| 21 | + |
| 22 | + if ($http_host != $server_name) { |
| 23 | + return 400 $http_host; |
| 24 | + } |
| 25 | + |
| 26 | + location {{ STATIC_URL }} { |
| 27 | + add_header 'Access-Control-Allow-Origin' '*'; |
| 28 | + add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; |
| 29 | + add_header 'Access-Control-Allow-Headers' 'X-Requested-With,Accept,Content-Type, Origin'; |
| 30 | + alias {{ STATIC_ROOT }}/; |
| 31 | + } |
| 32 | + |
| 33 | + location {{ MEDIA_URL }} { |
| 34 | + add_header 'Access-Control-Allow-Origin' '*'; |
| 35 | + add_header 'Access-Control-Allow-Methods' 'GET, OPTIONS'; |
| 36 | + add_header 'Access-Control-Allow-Headers' 'X-Requested-With,Accept,Content-Type, Origin'; |
| 37 | + alias {{ MEDIA_ROOT}}/; |
| 38 | + } |
| 39 | + |
| 40 | + location / { |
| 41 | + if ($request_method = 'OPTIONS') { |
| 42 | + |
| 43 | + add_header 'Access-Control-Allow-Origin' "$http_origin"; |
| 44 | + |
| 45 | + add_header 'Access-Control-Allow-Credentials' 'true'; |
| 46 | + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; |
| 47 | + |
| 48 | + add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; |
| 49 | + |
| 50 | + add_header 'Access-Control-Max-Age' 1728000; |
| 51 | + add_header 'Content-Type' 'text/plain charset=UTF-8'; |
| 52 | + add_header 'Content-Length' 0; |
| 53 | + |
| 54 | + return 204; |
| 55 | + } |
| 56 | + |
| 57 | + add_header 'Access-Control-Allow-Origin' "$http_origin" always; |
| 58 | + add_header 'Access-Control-Allow-Credentials' 'true' always; |
| 59 | + add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always; |
| 60 | + add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Accept,Origin' always; |
| 61 | + |
| 62 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 63 | + {% if ENV != "VAGRANT" %} |
| 64 | + proxy_set_header X-Forwarded-Proto http; |
| 65 | + {% else %} |
| 66 | + proxy_set_header X-Forwarded-Proto https; |
| 67 | + {% endif %} |
| 68 | + proxy_set_header Host $http_host; |
| 69 | + proxy_redirect off; |
| 70 | + proxy_pass http://localhost:{{ GUNI_PORT }}; |
| 71 | + } |
| 72 | +} |
| 73 | + |
| 74 | +{% if ENV != "VAGRANT" %} |
| 75 | +server { |
| 76 | + server_name www.{{ CURRENT_HOST }} |
| 77 | + www.{{ HOST }}; |
| 78 | + return 301 https://{{ CURRENT_HOST }}$request_uri; |
| 79 | +} |
| 80 | + |
| 81 | +server { |
| 82 | + server_name {{ HOST }}; |
| 83 | + listen 443 ssl; |
| 84 | + return 301 https://{{ CURRENT_HOST }}$request_uri; |
| 85 | +} |
| 86 | + |
| 87 | +server { |
| 88 | + server_name {{ CURRENT_HOST }} |
| 89 | + {{ HOST }}; |
| 90 | + listen 80; |
| 91 | + return 301 https://{{ CURRENT_HOST }}$request_uri; |
| 92 | +} |
| 93 | +{% endif %} |
0 commit comments