# Custom configuration

**URL:** <https://www.ruby-forum.com/t/custom-configuration/218312>\
**Category:** NGINX\
**Created:** [March 27, 2012, 11:47pm UTC](https://www.ruby-forum.com/t/custom-configuration/218312 "2012-03-27T23:47:30Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 27, 2012, 11:47pm UTC](https://www.ruby-forum.com/t/custom-configuration/218312/1 "2012-03-27T23:47:30Z")

</div>

Hi !

I’m using NGinx since few weeks.  
One of our customers wants his mp3 downloaded instead of being opened  
by the browser.

.htaccess aren’t read, so I’ve decided to add a config file for his  
domain, containing the “option” types, to add “mp3” as  
“application/octet-stream”.

It’s working well, but his website is now ugly, because the  
instruction also applies for .css O\_O

> root@shadow [/etc/cpnginx/custom]# cat [domain.com](http://domain.com)  
> types {  
> application/octet-stream mp3;  
> }

Is it a normal behavious, did I miss something?

## Thank you for your help !

Cheers, Adnan RIHAN.  
Président-Fondateur de l’association Virtual-Info (Loi 1901),  
hébergement Web et Serveurs de jeux.  
Technicien-Supérieur développeur d’applications Web et Système.  
3e année à {Epitech}.  
Envoyé de mon iPhone 

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 28, 2012, 12:16am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/2 "2012-03-28T00:16:34Z")

</div>

On Tue, 2012-03-27 at 23:46 +0200, Adnan RIHAN wrote:

> It’s working well, but his website is now ugly, because the  
> instruction also applies for .css O\_O
> 
> > root@shadow [/etc/cpnginx/custom]# cat [domain.com](http://domain.com)  
> > types {  
> > application/octet-stream mp3;  
> > }

When you use the types directive, it _replaces_ all the types with  
whatever you specify. You don’t define any mimetypes besides mp3, so  
Nginx uses the default (application/octet-stream) for anything it  
doesn’t recognize, which now includes css.

Try something like this instead:

location ~\* .mp3$ {  
types { application/octet-stream mp3; }  
}

See also:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

As an aside, you could also just edit /etc/nginx/mime.types and change  
the type for mp3 files.

Regards,  
Cliff

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 28, 2012, 7:16am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/3 "2012-03-28T07:16:54Z")

</div>

I’ve done this:

> root@shadow [/etc/cpnginx/custom]# cat mega-sound.be  
> location ~\* .mp3$ {  
> types {  
> application/octet-stream mp3;  
> }  
> }

But, after rebuilding vhost and restarted nginx, the mp3 are currently  
audio/mpeg (referring to firefox).  
Is there a way to check if the config is correctly “set” ?

## Thanks for your help.

Cordialement, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le mercredi 28 mars 2012 à 00:15, Cliff W. a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 28, 2012, 8:03am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/4 "2012-03-28T08:03:35Z")

</div>

On Wed, 2012-03-28 at 07:16 +0200, Adnan RIHAN wrote:

> audio/mpeg (referring to firefox).  
> Is there a way to check if the config is correctly “set” ?

Start by posting more of your configuration.

Cliff

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 28, 2012, 9:49am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/5 "2012-03-28T09:49:15Z")

</div>

I’m actually using NGinx as webserver, for a hosting service, with  
CPanel. CPNginx, the name of the module.

> root@shadow [/etc/cpnginx]# ls  
> ./ data.conf localkey.txt uninstall.sh  
> ../ direct/ md5.txt version.txt  
> cpanelproxy.conf expires/ nginx.cont.template vhost.conf  
> custom/ fileextensions.txt php.ini

> server\_name cpanel.\* www.cpanel._;  
> proxy\_redirect [http://www.cpanel](http://www.cpanel)._:8888 [http://www.cpanel](http://www.cpanel).\*;  
> access\_log off;  
> proxy\_busy\_buffers\_size 64k;  
> }  
> proxy\_read\_timeout 90;  
> proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
> client\_max\_body\_size 10m;  
> proxy\_pass [http://127.0.0.1:2077/](http://127.0.0.1:2077/);  
> location /whm-server-status {  
> access\_log /usr/local/apache/logs/access\_log;  
> proxy\_pass [http://127.0.0.1:8888/whm-server-status](http://127.0.0.1:8888/whm-server-status);  
> proxy\_set\_header Host $host;  
> proxy\_set\_header X-Real-IP $remote\_addr;  
> proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
> }  
> }

> http {  
> gzip\_buffers 4 32k;  
> gzip\_types text/plain application/x-javascript text/xml text/css;  
> ignore\_invalid\_headers on;  
> client\_header\_timeout 3m;  
> client\_body\_timeout 3m;  
> send\_timeout 3m;  
> include “/usr/local/nginx/conf/vhost.conf”;  
> include “/etc/cpnginx/cpanelproxy.conf”;  
> }

And finally

> root@shadow [/etc/cpnginx]# cat vhost.conf  
> client\_max\_body\_size 2000m;  
> client\_body\_buffer\_size 512k;  
> proxy\_send\_timeout 90;  
> proxy\_read\_timeout 90;  
> proxy\_buffer\_size 32k;  
> proxy\_buffers 16 32k;  
> proxy\_busy\_buffers\_size 64k;  
> proxy\_temp\_file\_write\_size 64k;  
> proxy\_connect\_timeout 30s;

In custom, there is only one file, containing the previous posted  
config.

Thanks for your help.

* * *

Ragards, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le mercredi 28 mars 2012 à 08:02, Cliff W. a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 28, 2012, 6:10pm UTC](https://www.ruby-forum.com/t/custom-configuration/218312/6 "2012-03-28T18:10:57Z")

</div>

Sorry but, did I paste enough config files ?

## Is there an error ? 😕

Regards, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le mercredi 28 mars 2012 à 09:48, Adnan RIHAN a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 28, 2012, 8:31pm UTC](https://www.ruby-forum.com/t/custom-configuration/218312/7 "2012-03-28T20:31:37Z")

</div>

Adnan,

For the following to work you need headers module installed:

```
           location ~ /(?<filename>(?!/).+\.mp3)$ {
              types {
                application/octet-stream mp3;
              }
              add_header Content-Disposition "attachment;

```

filename="$filename"";  
}

Kind regards,

Andrejs

Posted at Nginx Forum:

> **[Re: Custom configuration](https://forum.nginx.org/read.php?2,224499,224577#msg-224577)**
>
> Hi ! I'm using NGinx since few weeks. One of our customers wants his mp3 downloaded instead of being opened by the browser. .htaccess aren't read, so I've decided to add a config file for his domain, containing the "option" types, to add...

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 28, 2012, 7:15pm UTC](https://www.ruby-forum.com/t/custom-configuration/218312/8 "2012-03-28T19:15:22Z")

</div>

On Wed, 2012-03-28 at 09:48 +0200, Adnan RIHAN wrote:

Which vhost is the one in question? Can you paste _only_ the relevant  
server block? Most of what you pasted appears to be specific to running  
cPanel (I don’t have any cPanel installs to check).

Also, you mention stuff in “custom”, but I don’t see where any of the  
config you pasted includes a “custom” config.

Cliff

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 29, 2012, 12:58am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/9 "2012-03-29T00:58:34Z")

</div>

> Sorry but, what do you mean? Isn’t “headers” a standard module ? How  
> to check the compiled modules please ?

nginx -V

Try my solution, it works for me.

Andrejs

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,224499,224582#msg-224582](http://forum.nginx.org/read.php?2,224499,224582#msg-224582)

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 29, 2012, 12:51am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/10 "2012-03-29T00:51:10Z")

</div>

> Which vhost is the one in question? Can you paste _only_ the relevant  
> server block?

@Cliff: I didn’t find them 😕 I’ve asked the CPanel module devs to tell  
me where are the vhosts. Actually, I think nginx is just a “proxy” to  
apache, but it’s strange… It means apache is still running and  
.htaccess working… I’ll tell you as soon as I have the response.

> Also, you mention stuff in “custom”, but I don’t see where any of the  
> config you pasted includes a “custom” config.

My custom conf is in “/custom/”. This is what I had before @locojohn  
tip.

> root@shadow [/etc/cpnginx/custom]# cat mega-sound.be  
> location ~\* .mp3$ {  
> types {  
> application/octet-stream mp3;  
> }  
> }

> For the following to work you need headers module installed:  
> Sorry but, what do you mean? Isn’t “headers” a standard module ? How to  
> check the compiled modules please ?

> location ~ /(?(?!/).+.mp3)$ {  
> types {  
> application/octet-stream mp3;  
> } add\_header Content-Disposition “attachment; filename="$filename"”;  
> }

This is my new custom config file. Nothing changed. Still audio/mpeg 😕

* * *

Cordialement, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le mercredi 28 mars 2012 à 20:31, locojohn a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 29, 2012, 1:08am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/11 "2012-03-29T01:08:28Z")

</div>

@Cliff: Here is the customer’s vhost:

> root@shadow [/etc/cpnginx/custom]# cat /usr/local/nginx/conf/vhost.conf | grep  
> [domain.com](http://domain.com)  
> ########### Vhost configuration of mega-sound.be  
> server\_name [domain.com](http://domain.com) [www.domain.com](http://www.domain.com);  
> access\_log /usr/local/apache/domlogs/domain.com;  
> proxy\_redirect [http://www.domain.com:8888](http://www.domain.com:8888)[http://www.mega-sound.be](http://www.mega-sound.be);  
> proxy\_redirect [http://domain.com:8888](http://domain.com:8888)[http://domain.com](http://domain.com);  
> proxy\_redirect [http://domain.com:8888](http://domain.com:8888)[http://domain.com](http://domain.com);  
> include “/etc/cpnginx/custom/domain.com”;

@locojohn: Here is the custom file:

> root@shadow [/etc/cpnginx/custom]# cat [domain.com](http://domain.com)  
> location ~ /(?(?!/).+.mp3)$ {  
> types {  
> application/octet-stream mp3;  
> }  
> add\_header Content-Disposition “attachment; filename="$filename"”;  
> }

@locojohn: I’m using your custom config 😕 . Plus, here is my nginx -V:

> root@shadow [/etc/cpnginx/custom]# /usr/local/nginx/sbin/nginx -V  
> nginx version: nginx/1.0.11  
> built by gcc 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC)  
> configure arguments: --prefix=/usr/local/nginx --with-openssl=/usr/

When I access a .mp3, here is the answer:

> HTTP/1.1 200 OK  
> Server: nginx  
> Date: Wed, 28 Mar 2012 23:06:25 GMT  
> Content-Type: audio/mpeg  
> Content-Length: 8976405  
> Last-Modified: Mon, 26 Mar 2012 18:50:14 GMT  
> Connection: keep-alive  
> Expires: Thu, 29 Mar 2012 23:06:25 GMT  
> Cache-Control: max-age=86400  
> Accept-Ranges: bytes

Thank you for your help.

* * *

Cordialement, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le jeudi 29 mars 2012 à 00:57, locojohn a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 29, 2012, 1:22am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/12 "2012-03-29T01:22:25Z")

</div>

Unfortunately, it doesn’t work.  
Here is a link example: [http://www.mega-sound.be/adata/428.mp3](http://www.mega-sound.be/adata/428.mp3)

Actually, the first thing i’ve tried, is:

> types {  
> application/octet-stream mp3;  
> }

The only failure, is that with that, even CSS are downloaded (so, webste  
screwed up), and now I know that I HAVE to use “location”.

I gave you an example link, the mp3 are in:  
/home/customer/www/adata/428.mp3, they’re directly downloadable…

And poor me, the dev of CPNginx plugin told me that they don’t support  
custom config, so they won’t help me T\_T

* * *

Cordialement, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le jeudi 29 mars 2012 à 01:15, locojohn a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 29, 2012, 1:16am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/13 "2012-03-29T01:16:01Z")

</div>

Adnan, if it doesn’t set the “Content-Disposition” header as per my  
example, then it doesn’t match the location in which this header is set.  
It is likely that some other location has preference and so the code I  
provided will never be triggered. Look into your nginx config more  
closely. Also, check the error log, do you get any warnings?  
Sometimes, PCRE library may throw a warning, maybe you can use  
alternative location syntax compatible with an older version of PCRE:

…  
location ~ /(?P(?!/).+.mp3)$ {  
…

Are your mp3 links static at all?

Andrejs

Posted at Nginx Forum:

> **[Re: Custom configuration](https://forum.nginx.org/read.php?2,224499,224584#msg-224584)**
>
> Hi ! I'm using NGinx since few weeks. One of our customers wants his mp3 downloaded instead of being opened by the browser. .htaccess aren't read, so I've decided to add a config file for his domain, containing the "option" types, to add...

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 29, 2012, 2:37am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/14 "2012-03-29T02:37:06Z")

</div>

Mmmh…

Ok. I see, maybe there will never be any match, as there is only  
“proxy\_redirect” in vhosts;

> ########### Vhost configuration of mega-sound.be  
> server\_name mega-sound.be www.mega-sound.be;  
> access\_log /usr/local/apache/domlogs/mega-sound.be;  
> proxy\_redirect [http://www.mega-sound.be:8888](http://www.mega-sound.be:8888)  
> [http://www.mega-sound.be](http://www.mega-sound.be);  
> proxy\_redirect [http://mega-sound.be:8888](http://mega-sound.be:8888)[http://mega-sound.be](http://mega-sound.be);  
> proxy\_redirect [http://mega-sound.be:8888](http://mega-sound.be:8888)[http://mega-sound.be](http://mega-sound.be);  
> include “/etc/cpnginx/custom/mega-sound.be”;

Apache is still listening on :8888  
Is there a chance with this conf, to match any “location” as there is no  
“document\_root” or equivalent ?  
I mean, location is system based or URL based?

## If it’s system, I don’t know. If it’s URL based, there should be a match since the first test. Isn’t it ?

Cordialement, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le jeudi 29 mars 2012 à 02:15, Cliff W. a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 29, 2012, 2:16am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/15 "2012-03-29T02:16:45Z")

</div>

On Wed, 2012-03-28 at 19:15 -0400, locojohn wrote:

> Adnan, if it doesn’t set the “Content-Disposition” header as per my  
> example, then it doesn’t match the location in which this header is set.  
> It is likely that some other location has preference and so the code I  
> provided will never be triggered.

I’m fairly certain this is exactly what is happening. Either solution  
should work fine, but only if the location is properly matched.

Again, it’s not the preferred solution, but directly editing mime.types  
would probably work.

Cliff

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 30, 2012, 7:09am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/16 "2012-03-30T07:09:28Z")

</div>

Hi,

Finally I need your help 😕

The “CPNginx” devs have a website with a ticket support system, but  
they’re telling me that they don’t support custom configuration…  
I’ve told them I need their help because they know how they built their  
module and how they made it work, they still just answer “You need to do  
it by yourself”…

## What can I do T\_T ?

Regards, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le jeudi 29 mars 2012 à 02:36, Adnan RIHAN a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 30, 2012, 9:12am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/17 "2012-03-30T09:12:01Z")

</div>

Hey everybody !

Here are some news.  
I’ve compiled nginx with HttpHeadersMoreModule  
([GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/NginxHttpHeadersMoreModule)), to add custom  
headers in order to see if the location is or isn’t matched.

Here is what I tried:  
URL: [http://www.mega-sound.be/adata/428.mp3](http://www.mega-sound.be/adata/428.mp3)  
Custom config file:

> root@shadow [/etc/cpnginx/custom]# cat mega-sound.be  
> location ~\* .mp3$ {  
> more\_set\_headers ‘X-MyHeader: .mp3’;  
> }
> 
> location /adata {  
> more\_set\_headers ‘X-MyHeader: adata’;  
> }
> 
> more\_set\_headers ‘X-MyMasterHeader: set’;

The headers sent:

> Cache-Control: max-age=0  
> And received

> Accept-Ranges: bytes  
> Do you have an idea 😕 ?  
> Thank you for your help.

* * *

Cheers, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le vendredi 30 mars 2012 à 07:08, Adnan RIHAN a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 30, 2012, 10:37am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/18 "2012-03-30T10:37:08Z")

</div>

On Fri, Mar 30, 2012 at 07:08:37AM +0200, Adnan RIHAN wrote:

Hi there,

> What can I do T\_T ?

Read [How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html)

Look in your config file. Be aware of “include” directives. Look in  
every server{} block. Look at “listen” and “server\_name” directives in  
each server{} block.

Identify which one server{} block is being used to handle this request.

Post the config for that server{}.

(If you can additionally identify which one location{} block within  
that server{} block is being used for this request, then you could  
limit what you post to: the server{} block outside of all location{}s,  
plus the content of that one location{}. But that’s probably more work  
than is necessary.)

If you can enable the debug log (will probably require rebuilding  
nginx), then you will see lots of information about what nginx thinks  
is happening.

But posting the relevant part of the config file is the best way to make  
it easy for people help you.

## f

Francis D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 30, 2012, 5:45pm UTC](https://www.ruby-forum.com/t/custom-configuration/218312/19 "2012-03-30T17:45:41Z")

</div>

Ok.

Then, here is the vhost:

> root /home/megasoun/public\_html;
> 
> ```
> proxy_redirect http://www.mega-sound.be:8888 
> 
> ```

[http://www.mega-sound.be](http://www.mega-sound.be);

> client\_body\_buffer\_size 512k;  
> proxy\_set\_header Host $host;  
> proxy\_set\_header X-Real-IP $remote\_addr;  
> proxy\_set\_header X-Forwarded-For $proxy\_add\_x\_forwarded\_for;  
> }  
> include “/etc/cpnginx/custom/mega-sound.be”;  
> }

Here is the included file:

> more\_set\_headers ‘X-My2Header: $request\_uri’;  
> Here is the HTTP Headers for the root URL (www.mega-sound.be):

> Set-Cookie: slrememberme=deleted; expires=Thu, 01-Jan-1970 00:00:01 GMT  
> X-MyMasterHeader: set  
> X-My2Header: /  
> Content-Encoding: gzip

Here is the headers for an MP3 ([http://www.mega-sound.be/adata/362.mp3](http://www.mega-sound.be/adata/362.mp3)):

> Cache-Control: max-age=86400  
> Accept-Ranges: bytes

## Is it enough ? Thank you for your help.

Cordialement, Adnan RIHAN.  
Président-Fondateur de l’association (de loi 1901) Virtual-Info  
([http://www.virtual-info.info/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

Le vendredi 30 mars 2012 à 10:36, Francis D. a écrit :

---

<div class="post-metadata">

**Author:** ![Adnan\_RIHAN](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/4af34b/32.png) [@Adnan\_RIHAN](https://www.ruby-forum.com/u/Adnan_RIHAN)\
**Post date:** [March 31, 2012, 1:36am UTC](https://www.ruby-forum.com/t/custom-configuration/218312/20 "2012-03-31T01:36:23Z")

</div>

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/](http://www.virtual-info.info/)), hébergeur Web et Serveurs de Jeux.  
Consultant ([http://rihan.fr/](http://rihan.fr/))-Technicien Supérieur en Informatique de  
Gestion.  
Ambassadeur Qt ([YOURLS — Your Own URL Shortener | https://lyt.me/](http://lyt.me/7E)) (Projet Tag-PG  
([http://rihan.fr/fr/projets/tagpg](http://rihan.fr/fr/projets/tagpg))).

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

[Next page](https://www.ruby-forum.com/t/custom-configuration/218312.md?page=2)
