Custom configuration

Adnan RIHAN adnan at rihan.fr
Fri Mar 30 23:35:52 UTC 2012



I knew that location are matched 1 time but I didn't noticed the |mp3 T_T  

Thank you very much, I'm understanding more and more nginx.
I think it's done, I just have to deal with the CPanel NGinx module devs to change include place (in order to avoid this case another time).

Good night !
---
Cordialement, Adnan RIHAN.
Président-Fondateur de l'association (de loi 1901) Virtual-Info (http://www.virtual-info.info/), hébergeur Web et Serveurs de Jeux.
Consultant (http://rihan.fr/)-Technicien Supérieur en Informatique de Gestion.
Ambassadeur Qt (http://lyt.me/7E) (Projet Tag-PG (http://rihan.fr/fr/projets/tagpg)).


Le vendredi 30 mars 2012 à 20:14, Francis Daly a écrit :

> On Fri, Mar 30, 2012 at 05:45:05PM +0200, Adnan RIHAN wrote:
>  
> Hi there,
>  
> > Then, here is the vhost:
>  
> Great, this shows why things are working the way they are.
>  
> > > location ~* ^.+.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|iso|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|mp3|ogv|ogg|flv|swf|mpeg|mpg|mpeg4|mp4|avi|wmv|js|css)$ {
>  
> This is the first regex location that matches mp3 urls, so this is the
> one that will be used.
>  
> For what I think you want to do, you should remove "|mp3" from up there,
> and then have the separate "~* \.mp3$" location later.
>  
> > > expires 24h;
> > > root /home/megasoun/public_html;
> > > error_page 404 = @apache;
> > > access_log /usr/local/apache/domlogs/mega-sound.be (http://mega-sound.be);
> > > log_not_found off;  
> > >  
> >  
>  
>  
> Based on the rest of the config, you can probably move some of those to
> "outside all locations", so that they will be inherited into all locations
> that don't otherwise set them.
>  
> <snippage>
> > > location / {
> > > proxy_pass http://87.98.132.48:8888/;
> > > }
> > >  
> >  
>  
>  
> > > location @apache {
> > > proxy_pass http://87.98.132.48:8888;
> > > }
> > >  
> >  
>  
>  
> > > include "/etc/cpnginx/custom/mega-sound.be (http://mega-sound.be)";
> > > }
> > >  
> >  
>  
>  
> > > root at shadow [/usr/local/nginx/conf]# cat /etc/cpnginx/custom/mega-sound.be (http://mega-sound.be)
>  
> As above, because this is included last in the main file, the mp3 location
> here can never match.
>  
> So if you remove the "|mp3" up there, then this one will match:
>  
> > > location ~* \.mp3$ {
> > > more_set_headers 'X-MyHeader: .mp3';
> > >  
> >  
>  
>  
> and now you can set your types, or do whatever else is needed, and have
> it take effect.
>  
> (If your default or server-level "root" is not correct for this location,
> you'll want to set that in here too.)
>  
> Because of the nginx location matching rules, this next location won't
> be used for /adata/123.mp3, but will be used for /adata/123.html. You can
> test that by putting a file of the right name in the right ("root"/adata)
> directory, and seeing the X- header appearing.
>  
> > > location /adata {
> > > more_set_headers 'X-MyHeader: adata';
> > > }
> > >  
> >  
>  
>  
> And these two are outside of all locations, so apply to everything that
> does not override them.
>  
> > > more_set_headers 'X-MyMasterHeader: set';
> > > more_set_headers 'X-My2Header: $request_uri';
> > >  
> >  
>  
>  
> > Here is the HTTP Headers for the root URL (www.mega-sound.be (http://www.mega-sound.be)):
>  
> This is expected to be proxy_pass'ed to port 8888, and you can see that
> your "all" more_set_headers directives did apply.
>  
> > > HTTP/1.1 200 OK
> > > X-MyMasterHeader: set
> > > X-My2Header: /
> > >  
> >  
>  
>  
> > Here is the headers for an MP3 (http://www.mega-sound.be/adata/362.mp3):
>  
> This would match your original long location, so will be the file
> /home/megasoun/public_html/adata/362.mp3 if it exists, and proxied to
> port 8888 if it doesn't. Again, your "all" more_set_headers apply.
>  
> > > HTTP/1.1 200 OK
> > > Content-Type: audio/mpeg
> > > X-MyMasterHeader: set
> > > X-My2Heade: /adata/362.mp3
> > >  
> >  
>  
>  
> If you remove "|mp3" from the first location; or just "include" this file
> at the top instead of the bottom of the server{} block, then your custom
> mp3 location would apply; and you should see your extra configuration
> being used. (Without "root" set right, though, you may just end up with
> a 404.)
>  
> http://www.nginx.org/r/location for the details on how nginx chooses
> which one location{} block will be used for the current request, if
> it's unclear.
>  
> All the best,
>  
> f
> --  
> Francis Daly francis at daoine.org (mailto:francis at daoine.org)
>  
> _______________________________________________
> nginx mailing list
> nginx at nginx.org (mailto:nginx at nginx.org)
> http://mailman.nginx.org/mailman/listinfo/nginx
>  
>  


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120331/e96068f3/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Capture =?utf-8?Q?d=E2=80=99e=CC=81cran_?=2012-03-31 =?utf-8?Q?a=CC=80_?=01.34.16.png
Type: image/png
Size: 29857 bytes
Desc: not available
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20120331/e96068f3/attachment-0001.png>


More information about the nginx mailing list