Last active
August 29, 2015 13:57
-
-
Save derekperkins/9415754 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// API | |
server { | |
listen 80; | |
root /home/nozzle/htdocs/webroot; | |
index index.php; | |
server_name api.nozzle.io; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
location ~ \.php$ { | |
if ($http_origin ~* (https?://.*\.nozzle\.io/?)) { | |
set $cors "true"; | |
} | |
if ($request_method = 'OPTIONS') { | |
set $cors "${cors}options"; | |
} | |
# non-OPTIONS indicates a normal CORS request | |
if ($request_method = 'GET') { | |
set $cors "${cors}get"; | |
} | |
if ($request_method = 'POST') { | |
set $cors "${cors}post"; | |
} | |
# if it's a GET or POST, set the standard CORS responses header | |
if ($cors = "trueget") { | |
add_header 'Access-Control-Allow-Origin' "$http_origin"; | |
add_header 'Access-Control-Allow-Credentials' 'true'; | |
} | |
if ($cors = "truepost") { | |
add_header 'Access-Control-Allow-Origin' "$http_origin"; | |
add_header 'Access-Control-Allow-Credentials' 'true'; | |
} | |
if ($cors = "trueoptions") { | |
add_header 'Access-Control-Allow-Origin' "$http_origin"; | |
add_header 'Access-Control-Allow-Credentials' 'true'; | |
add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS'; | |
add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,Accept,Origin,User-Agent,DNT,Cache-Control,X-Mx-ReqToken,Keep-Alive,X-Requested-With,If-Modified-Since'; | |
add_header 'Content-Length' 0; | |
return 204; | |
} | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass unix:/var/run/nozzle-php5-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
} | |
location /robots.txt { | |
rewrite ^/robots.txt$ /robots.txt.php last; | |
} | |
} | |
// APP | |
server { | |
listen 80; | |
root /home/angular/angular/app; | |
index index.html; | |
server_name app.nozzle.io; | |
location ~* \.(?:ico|css|js|gif|jpe?g|png)$ { | |
expires -1; | |
add_header Pragma "no-cache"; | |
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"; | |
add_header Vary Accept-Encoding; | |
access_log off; | |
} | |
location / { | |
expires -1; | |
add_header Pragma "no-cache"; | |
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0"; | |
try_files $uri $uri/ /index.html =404; | |
} | |
location /login { | |
index login.html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment