I am trying to get nginx to work with my pushState-based URI handling that backbone.js manages for me in an Javascript app.
R
Since there may be ajax request api, the following suits for this case,
server {
listen 80;
server_name example.com;
root /var/www/example.com;
# Any route containing a file extension (e.g. /devicesfile.js)
location ~ ^.+\..+$ {
try_files $uri =404;
}
# Any route that doesn't have a file extension (e.g. /devices)
location / {
try_files $uri /index.html;
}
# The location block above provides the shortest prefix, of length one,
# and so only if all other location blocks fail to provide a match,
# this block will be used.
# Ajax api starts with /v1/ will be proxied
location /v1/ {
proxy_pass http://proxy;
}
}