location matching.

Francis Daly francis at daoine.org
Mon May 13 11:07:31 UTC 2013


On Sun, May 12, 2013 at 03:25:56PM +0100, Steve Wilson wrote:

Hi there,

I see from the end of the thread that you have a working system now by
using separate server{} blocks, so that's all good.

It might be interesting to see why the original did not do what you
wanted, and to see whether there is a reasonable way of not using two
server{} blocks.

Feel free to ignore this if it's not interesting to you :-)

> I've just had to move subversion onto a server that's already serving
> network wordpress via nginx. Most things work via /svn in a subversion
> client but I can't for the life of me figure out how to stop /svn.*\.php
> hitting the fastcgi_pass.

The incoming request is for "/svn/live/s.php".

The only location{} blocks are

>         location ~ /svn {
>         location ~ \.(php|php5) {
>         location / {
>         location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {

and, of those, this request should be handled in the first one. But you
report that it is actually handled in the second.

As well as the location{} blocks, there are server-level rewrites and if()
blocks, which will take effect before the location-matching.

>         rewrite /wp-admin$ $scheme://$host$uri/ permanent;

That one doesn't apply here.

>         rewrite /files/$ /index.php last;

Neither does that one.

>         set $cachetest
> "$document_root/wp-content/cache/ms-filemap/${host}${uri}";
>         if (-f $cachetest) {

That most likely doesn't, but it can't be guaranteed.

>         if ($uri !~ wp-content/plugins) {

That "if" does apply, but the following rewrite doesn't.

>         if (!-e $request_filename) {

That "if" most likely does apply, so the next rewrites are tried...

>             rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
>             rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
>             rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;

and the third one there matches, so there's an internal rewrite to
"/live/s.php", and the location match actually starts with that uri.

Which matches the second location{} block above, and is consistent with
what you report.


It looks like your "wordpress" nginx config (which is similar
to what is currently on both http://wiki.nginx.org/WordPress and
http://codex.wordpress.org/Nginx) assumes that wordpress is the only
purpose of this nginx server.

It would probably take quite a bit of testing to safely get rid of the
assumptions made in the server-level "if" and "rewrite" directives
used. It looks like some could probably be replaced with location{}
blocks, but "some" isn't "all".

So, unless someone has the time and inclination to re-do and test that
to allow one server{} block share wordpress and anything else, it looks
like the simple change is to use a separate server{} block for wordpress.


Which is what you did.

Cheers,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list