Location ~ \.php$ does not work with proxy_pass breaks pretty permalinks

I am using Nginx as a frontend server to server only static files, and
apache as the backend server to serve only php file. I saw a
configuration for proxy_pass that would allow me to be 100% sure I was
only serving php files by using the expression~ .php$. I saw this from
a reply from Igor in Reverse Proxy with caching

I am currently using:

server …

location / {
proxy_pass http://127.0.0.1:8008;

location ~
.(html|htm|xml|css|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /var/www/mydomain;
index index.php index.html index.htm;

In the static location I can isolate what is served by Nginx to just the
files listed, but in the proxy_pass location I can only use “/” so I
can’t be sure only php files are served by apache. I would like to use
the following:

location ~ .php$ {
proxy_pass http://127.0.0.1:8008;

This works with fast_cgi, but not with proxy_pass.

When I do use ~ .php$ I can only see the homepage, but not the post
pages, page2, or anything but the home page. I am using Wordpress with
pretty permalinks. I also use WP Super Cache.

How do I know I am only serving php files with Apache? Is there an
expression I can use to force the location for proxy_pass to only serve
php files without breaking my pretty permalinks?

Posted at Nginx Forum:

My question was answered in this other thread:

Posted at Nginx Forum:

Here is an example:

The homepage loads normally at the address http://www.nerdgrind.com/,
but anything else, for example Nerd Grind or
single article pages like the example above, won’t load at all.

All the best,

Todd

Posted at Nginx Forum:

I tried to use ~ .php$ again today to only serve php pages with the
backend with proxy_pass but I got this error:

404 Not Found

Todd

Posted at Nginx Forum:

X-Subject: Re: location ~ .php$ does not work with proxy_pass breaks
pretty
permalinks

On Wed, Dec 02, 2009 at 03:24:31AM -0500, nerdgrind wrote:

           root   /var/www/mydomain;

How do I know I am only serving php files with Apache? Is there an expression I can use to force the location for proxy_pass to only serve php files without breaking my pretty permalinks?

How do these pretty permalink URLs look ?


Igor S.
http://sysoev.ru/en/