Forum: NGINX mmagic word in nginx?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Daniel E. (Guest)
on 2009-03-02 00:47
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?
Maxim D. (Guest)
on 2009-03-02 01:27
(Received via mailing list)
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 "/<somethig>tar" as well as
"/<something>.tar".

Maxim D.
Daniel E. (Guest)
on 2009-03-02 10:17
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!
Igor S. (Guest)
on 2009-03-02 10:40
(Received via mailing list)
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.....)$ {
Daniel E. (Guest)
on 2009-03-02 10:49
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!
This topic is locked and can not be replied to.