Nginx location block for specific path and certain file types Nginx location block for specific path and certain file types wordpress wordpress

Nginx location block for specific path and certain file types


I had similar problem with my images. In my applications, images were being served from two different locations.

You can specify different sources based on url pattern. Your solution would then look something like this.

location ~* ^/blog/.+\.(xml)$ {    root /some/path/;    expires 90d;}location ~* \.(xml|js|jpg|png|css|html|otf|eot|svg|ttf)$ {    root /some/other/path/;    expires 30d;    index index.html;}


Gotta escape that period

server {    location ~* ^/blog/.*\.xml$ {        proxy_pass http://127.0.0.1:8080;    }}