Welcome! Log In Create A New Profile

Advanced

Re: Custom configuration

All files from this thread

File Name File Size   Posted by Date  
Capture =?utf-8?Q?d=E2=80=99e=CC=81cran_?=2012-03-31 =?utf-8?Q?a=CC=80_?=01.34.16.png 29.2 KB open | download Adnan RIHAN 03/30/2012 Read message
Francis Daly
March 30, 2012 02:16PM
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;
> > 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";
> > }

> > root@shadow [/usr/local/nginx/conf]# cat /etc/cpnginx/custom/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):

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@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Custom configuration

Adnan RIHAN March 27, 2012 05:48PM

Re: Custom configuration

Cliff Wells March 27, 2012 06:16PM

Re: Custom configuration

Adnan RIHAN March 28, 2012 01:18AM

Re: Custom configuration

Cliff Wells March 28, 2012 02:04AM

Re: Custom configuration

Adnan RIHAN March 28, 2012 03:50AM

Re: Custom configuration

Adnan RIHAN March 28, 2012 12:12PM

Re: Custom configuration

Cliff Wells March 28, 2012 01:16PM

Re: Custom configuration

locojohn March 28, 2012 02:31PM

Re: Custom configuration

Adnan RIHAN March 28, 2012 06:52PM

Re: Custom configuration

locojohn March 28, 2012 06:57PM

Re: Custom configuration

Adnan RIHAN March 28, 2012 07:08PM

Re: Custom configuration

locojohn March 28, 2012 07:15PM

Re: Custom configuration

Adnan RIHAN March 28, 2012 07:22PM

Re: Custom configuration

Cliff Wells March 28, 2012 08:16PM

Re: Custom configuration

Adnan RIHAN March 28, 2012 08:38PM

Re: Custom configuration

Adnan RIHAN March 30, 2012 01:10AM

Re: Custom configuration

Adnan RIHAN March 30, 2012 03:12AM

Re: Custom configuration

Francis Daly March 30, 2012 04:38AM

Re: Custom configuration

Adnan RIHAN March 30, 2012 11:46AM

Re: Custom configuration

Francis Daly March 30, 2012 02:16PM

Re: Custom configuration Attachments

Adnan RIHAN March 30, 2012 07:38PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 104
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready