Mmagic word in nginx?


#1

Hi,

I’m using nginx 0.6.32 on my server and I ran into misterious an issue.
One of my client is istalled the Drupal CMS and noticed that one part of
the portal is not working.

When you enter somedomain/mypage it works great, but when you try to
reach somedomain/naptar nginx gives a 404 error.

I’ve managed to reproduce the issue using the same rewrite settings:
location / {
root /home/{domain_here}/httpdocs;
index index.php index.html;

    if (!-e $request_filename) {
        rewrite  ^/(.*)$  /index.php?q=$1  last;
        break;
    }
}

It strange that the error only occures when I try to reach
somedomain/naptar
The word naptar - calendar in Hungarian BTW - does not exist in my
config file. There is no file/directory by this name in the server.

Any idea?


#2

Hello!

On Sun, Mar 01, 2009 at 11:47:40PM +0100, Daniel Epi wrote:

location / {
somedomain/naptar
The word naptar - calendar in Hungarian BTW - does not exist in my
config file. There is no file/directory by this name in the server.

Any idea?

Probably something like

location ~ ^(.*).(jpg|gif|tar|gz|...)$ {
    ...
}

exists in your config file to catch static. As you can see the
above regexp is wrong (missing “”, not even talking about
unneeded “^(.*)”) and will catch “/tar” as well as
“/.tar”.

Maxim D.


#3

Hi Maxim!

Thanks for the reply. You’re absolutly right.
The for static contect caught the url.

I’ll cahnge it to:
location ~* ^.+.(jpg|jpeg|gif…)$ {

}
as shown in the example (http://wiki.codemongers.com/NginxFullExample2)

Thank you!


#4

Igor S. wrote:

I’m not sure, but probably single anchor (^ and $) regex will be faster:

  • location ~* ^.+.(jpg|jpeg|gif…)$ {
  • location ~* .(jpg|jpeg|gif…)$ {

Thanks for the suggestion Igor!
I’ll give it a try.

Thanks!


#5

On Mon, Mar 02, 2009 at 09:17:02AM +0100, Daniel Epi wrote:

Hi Maxim!

Thanks for the reply. You’re absolutly right.
The for static contect caught the url.

I’ll cahnge it to:
location ~* ^.+.(jpg|jpeg|gif…)$ {

}
as shown in the example (http://wiki.codemongers.com/NginxFullExample2)

I’m not sure, but probably single anchor (^ and $) regex will be faster:

  • location ~* ^.+.(jpg|jpeg|gif…)$ {
  • location ~* .(jpg|jpeg|gif…)$ {