Skip to content

Instantly share code, notes, and snippets.

@Matrixbirds
Last active August 25, 2016 08:18
Show Gist options
  • Save Matrixbirds/84b806616f538f4df7d52e1ffe4dd608 to your computer and use it in GitHub Desktop.
Save Matrixbirds/84b806616f538f4df7d52e1ffe4dd608 to your computer and use it in GitHub Desktop.
A simple SPA Nginx demo
## try_files all request except /api, /admin/api
upstream backend_api {
server ip_address;
}
server {
listen 80;
server_name t66y.domain.com;
index index.html;
charset utf-8;
location /index.html {
proxy_pass http://backend_api;
proxy_redirect off;
}
location / {
try_files $uri $uri/ /index.html;
}
location ~ ^/(api|admin/api)/ {
proxy_pass http://backend_api;
proxy_redirect off;
}
location /admin/api {
proxy_pass http://backend_api;
proxy_redirect off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment