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

nerdgrind nginx-forum at nginx.us
Wed Dec 2 11:24:31 MSK 2009

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 http://forum.nginx.org/read.php?2,13955

I am currently using:

server ...

location / {

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$ {

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: http://forum.nginx.org/read.php?2,27301,27301#msg-27301

More information about the nginx mailing list