On Sat, Mar 29, 2014 at 12:12 PM, Adie Nurahmadie wrote:


On Sat, Mar 29, 2014 at 11:50 PM, Doc  < [email protected] <javascript:parent.wgMail.openComposeWindow('[email protected]')>
 wrote:
On my site, music can be played by going to  http://mysite.com/music/billyjoel/song.mp3 <http://mysite.com/music/billyjoel/song.mp3>  (for example). You can download the same song by going to  http://mysite.com/music/billyjoel/download/song.mp3 <http://mysite.com/music/billyjoel/download/song.mp3> .

The path including "download" is aliased and the default mime type changed as shown here:

location /music/billyjoel/play/ {
    types{
        audio/mp3 mp3;
    }
}

location /music/billyjoel/download/ {
    types{}
    default_type application/octet-stream;
    alias /(location of root goes here)/music/billyjoel/play/;
}

This works as intended. However, I set expires and access_log directives for css/jpg/woff, etc. like this and the mp3 will no longer download and I get a 404 with a "file not found" error in the error logs:

location ~* ^.+\.(mp3|jpg|css)$ {
    expires modified +30d;
    access_log off;
}


Location with regex will get matched first, 

Ack! Yes. Exactly. I keep forgetting that. Thank you.

Looks like the download request for mp3 files get served by: ` location ~* ^.+\.(mp3|jpg|css)$` and since you didn't set any alias or location over there, it will returns 404.
 
_______________________________________________
nginx mailing list
[email protected] <javascript:parent.wgMail.openComposeWindow('[email protected]')> http://mailman.nginx.org/mailman/listinfo/nginx <http://mailman.nginx.org/mailman/listinfo/nginx>


 <http://mailman.nginx.org/mailman/listinfo/nginx>
-- 
regards,
Nurahmadie
--

On Sat, Mar 29, 2014 at 11:50 PM, Doc < [email protected] <javascript:parent.wgMail.openComposeWindow('[email protected]')>
wrote:
On my site, music can be played by going to http://mysite.com/music/billyjoel/song.mp3 <http://mysite.com/music/billyjoel/song.mp3> (for example). You can download the same song by going to http://mysite.com/music/billyjoel/download/song.mp3 <http://mysite.com/music/billyjoel/download/song.mp3> .

The path including "download" is aliased and the default mime type changed as shown here:

location /music/billyjoel/play/ {
    types{
        audio/mp3 mp3;
    }
}

location /music/billyjoel/download/ {
    types{}
    default_type application/octet-stream;
    alias /(location of root goes here)/music/billyjoel/play/;
}

This works as intended. However, I set expires and access_log directives for css/jpg/woff, etc. like this and the mp3 will no longer download and I get a 404 with a "file not found" error in the error logs:

location ~* ^.+\.(mp3|jpg|css)$ {
    expires modified +30d;
    access_log off;
}

_______________________________________________
nginx mailing list
[email protected] <javascript:parent.wgMail.openComposeWindow('[email protected]')> http://mailman.nginx.org/mailman/listinfo/nginx <http://mailman.nginx.org/mailman/listinfo/nginx>


 <http://mailman.nginx.org/mailman/listinfo/nginx>
--
regards,
Nurahmadie
--

------------------------------

_______________________________________________
nginx mailing list
[email protected] <javascript:parent.wgMail.openComposeWindow('[email protected]')>   <javascript:parent.wgMail.openComposeWindow('[email protected]')> http://mailman.nginx.org/mailman/listinfo/nginx <http://mailman.nginx.org/mailman/listinfo/nginx>   <http://mailman.nginx.org/mailman/listinfo/nginx>
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to