How do I configure a location block to always return a single file in nginx?

Solution 1:

Just tested this and it works for me:

server {
    root /tmp/root;
    server {
        listen 8080;
        location /static {
            try_files $uri =404;
        }
        location / {
            rewrite ^ /static/index_debug.html break;
        }
    }
}

The file /tmp/root/static/index_debug.html exists of course :)

I can hit any URL and I just get the static page.