Nginx location, alias, rewrite, root

I serve / foo / bar / through proxypass and want to keep doing this. However, I would like to install /foo/bar/baz.swf statically from the site /var/www/mystatic/baz.swf, etc.

I was hoping I could do something like

location /foo/bar/(.*) { alias /var/www/mystatic/; } location / { proxy_pass ....; ... } 

And / foo / bar / will go to the application server while / foo / bar / (. *) Is served statically.

The docs say that I cannot do this and you need to use the root combination and rewrite: http://wiki.nginx.org/NginxHttpCoreModule

Adding to the complication, I would like to continue to use the ancient, unsupported 0.5.33. Any help would be greatly appreciated.

Edit: move forward, someone suggested using root instead of an alias. But it seems like I can't use any regex in the location directive with my version? Here, /foo/bar/baz.swf is served by proxy_pass! I have a file on /var/www/foo/bar/baz.swf.

  location /foo/bar/(.+) { root /var/www/; } 
+4
source share
3 answers

Can you do this; but he is a little esoteric. Try using:

 location ^~ /foo/bar { alias /var/www/mystatic/; } location / { proxy_pass ....; } 

These parameters are documented in the Wiki http://wiki.nginx.org/NginxHttpCoreModule#location

+2
source
 location = /foo/bar/baz.swf {} 

clears all options set in /foo/bar/baz.swf. Therefore, you can leave this where it is, since the proxy settings will not be used.

+1
source

You can:

 # mkdir /var/www/foo # mv /var/www/mystatic /var/www/foo/bar 

then use this configuration:

 location ~ ^/foo/bar/(.+) { root /var/www/; } 
+1
source

All Articles