fast-cgi Oddness

Francis Daly francis at daoine.org
Tue Feb 18 20:13:07 UTC 2020


On Thu, Feb 13, 2020 at 03:46:53PM -0500, CJ Ess wrote:

Hi there,

> curl -H "Host: x.com" "http://127.0.0.1/wp-admin/"
> Which succeeds - I can see in the php-fpm log that it does "GET
> /wp-admin/index.php"
> 
> I have a second test case:
> curl -H "Host: x.com" "http://127.0.0.1/wp-admin/load-styles.php"
> Which unexpectedly returns a 404 error, even though the file does exist at
> wp-admin/load-styles.php, but in the php-fpm log I am seeing GET
> /load-styles.php

> I can not figure out why the path is altered for the failing test case and
> not the passing one.

>   if (!-e $request_filename) {
>     rewrite  ^/[_0-9a-zA-Z-]+(/wp-(content|admin|includes).*) $1 break;
>     rewrite  ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 break;
>   }

Assuming that /usr/local/nginx/html/wp-admin does not exist:

/wp-admin/ does not match either rewrite, so is unchanged.

/wp-admin/load-styles.php matches the second, so is rewritten to
/load-styles.php.

>   location / {
>     rewrite ^/wp-admin$ /wp-admin/ permanent;
>     root      /x;
>     index     index.php;
>     try_files $uri @wordpress;
>   }
> 
>   location @wordpress {
>     root          /x/wordpress;
>     include       /etc/nginx/fastcgi_params;
>     fastcgi_pass  127.0.0.1:9000;
>     fastcgi_index index.php;
> 
>     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

That is /x/wordpress/wp-admin/index.php in the first case, and
/x/wordpress/load-styles.php in the second.

Why do the first rewrites exist? Are they breaking your setup?

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list