Welcome! Log In Create A New Profile

Advanced

Re: Apparent bug in rewrite (0.7.65)

Maxim Dounin
January 02, 2011 11:54PM
Hello!

On Sun, Jan 02, 2011 at 02:58:29PM -0500, mschipperheyn wrote:

> I have an apparent bug in nginx 0.7.65
>
> My config
> [code]
> server {
> listen 80;
> server_name assets.mysite.com;
> root /usr/share/apache-tomcat-6.0.24/webapps/ROOT/assets;
>
> rewrite ^/([^/]+)/(.*) /$2;
> expires 90d;
> }
> [/code]
>
> My request
> [code]
> 2011/01/02 19:51:52 [error] 5824#0: *18 open()
> "/usr/share/apache-tomcat-6.0.24/webapps/ROOT/assets/style.css" failed
> (2: No such file or directory), client: xxx, server: assets.mysite.com,
> request: "GET /28/css/style.css HTTP/1.1", host: "assets.mysite.com"
> [/code]
>
> >From this it looks like
> http://www.mysite.com/28/css/style.css
> gets munged to
> /style.css
> when it should be
> /css/style.css
>
> On apache this works fine and I checked the regex on
> http://www.regexplanet.com/simple/ which suggests it's just fine.
>
> Any suggestions?

By defining rewrite at server level and not using location / you
actually define two rewrites: one at server level, and the same
one in implicit location. Or, in other words, server rewrites are
also location-level rewrites in implicit location.

Use this instead:

server {
...

location / {
rewrite ^/([^/]+)/(.*) /$2 break;
}
}

Just adding "location / {}" whould do the trick as well, but being
explicit is a good idea.

Maxim Dounin

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

Apparent bug in rewrite (0.7.65)

mschipperheyn January 02, 2011 02:58PM

Re: Apparent bug in rewrite (0.7.65)

mschipperheyn January 02, 2011 03:04PM

Re: Apparent bug in rewrite (0.7.65)

Maxim Dounin January 02, 2011 11:54PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 70
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready