Skip to content

Instantly share code, notes, and snippets.

@uggedal
Created May 28, 2013 17:28
Show Gist options
  • Save uggedal/5664489 to your computer and use it in GitHub Desktop.
Save uggedal/5664489 to your computer and use it in GitHub Desktop.
Multiple location match in nginx
location ~ ^/(.*)/(.*)/other/stuff/(.*)/this-is-static {
location /static-cache {
# root/alias or other config here
}
try_files /static-cache/$1/$2/$3/this-is-static @app;
}
# or
location ~ ^/(.*)/(.*)/other/stuff/(.*)/this-is-static {
# if you use static-cache in other location blocks and/or the root scope:
include static-cache.conf;
try_files /static-cache/$1/$2/$3/this-is-static @app;
}
@uggedal
Copy link
Author

uggedal commented May 28, 2013

This does not work at all since the inner location needs to be a more specific variant of the outer location.

@cjohansen
Copy link

I tried this, except with the location /static-cache part outside. Didn't work :/

@cjohansen
Copy link

Oh, scratch that, I missed out on the ~ part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment