I've got the following Nginx config:
server {
listen 80;
server_name mercury;
access_log /var/log/nginx/mercury.access.log;
error_log /var/log/nginx/mercury.error.log;
location /static {
add_header Cache-Control: max-age=31536000;
}
location / {
root /opt/the-jam/www/dist/;
try_files $uri /index.html;
add_header Cache-Control: max-age=60;
}
}
And I've got the directory structure:
§ tree /opt/the-jam/www/dist
/opt/the-jam/www/dist
├── index.html
└── static
├── 3522b60dabd4468d03f8.css
└── 3522b60dabd4468d03f8.js
And I'm getting the error:
2015/10/20 14:25:26 [error] 4529#0: *95 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: 0.0.0.0, server: the-jam, request: "GET /favicon.ico HTTP/1.1", host: "the-jam.example.com", referrer: "http://the-jam.example.com/"
This is a single-page app where any request, i.e. /foo/bar/baz
should just load /index.html
, unless it's requesting something in /static/[hash].js
, so my understanding is that the try_files
directive will try load the file at /foo/bar/baz
, and then fall back to /index.html
, so why am I getting the redirection cycle?