Easy engine nginx locations.conf

Hi,

I have run into a bit of an issue with the easyengine common/locations.conf.

location ~* \.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|tgz|gz|rar|bz2|doc|xls|exe|ppt|zip|tar|mid|midi|wav|bmp|rtf)$ { access_log off; log_not_found off; expires max; }

If I try to serve downloads from a specific location conf below in the vhost conf for example:

location /downloads/ {
root /var/www/downloads/;
}

The only way the ‘download.zip’ works is if I remove the zip extension from the common locations directive.

Is there any way to retain the zip extension and yet serve the file from a specific directory like /var/www/downloads, which is a location outside the defined root for the specific domain.

Thanks

@raul
you dont need to remove .zip extension from locations.conf
just put following rule in nginx configuration

location  ~* /download/ {  
		  root /var/www/; 	  
	}  

Hi Harshad,

Thanks for your input. I just tried that, but I am still getting a 404 not found error. The moment I remove the zip extension it works.

I guess this is one of those edgecases, I am guessing this is something to do with the fact the that location file extension cache directive only applies to the defined root in this case /var/www/example.com/htdocs and the download directory is outside that at /var/www/downloads.

Hi Harshad,

My bad, it’s working, I was using alias instead of root in the directive and forgot to change it.

alias /var/www/downloads/;

instead of

root /var/www/;

as you suggested. I just changed it to root and its working.
Is there any way to use alias here?

Thanks a ton! I really envy how good you guys are with Nginx!

@raul
i have tested as per your issue, i have download location at /var/www/download/
if you are still having issue, try removing nginx cache.
can you give me your download link??

Ok I got it working with alias too, I really don’t understand the regex properly yet,

for root this works:

location ~* /downloads/ {
root /var/www/;
}

but ~* does work with alias

for alias this works:
location ^~ /downloads/ {
alias /var/www/downloads/;
}

1 Like

@raul
We are glad that you got it working. Thanks for update.