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

Igor Sysoev igor at sysoev.ru
Wed Dec 2 13:21:01 MSK 2009


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:

> 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 / {
>             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?

How do these pretty permalink URLs look ?


-- 
Igor Sysoev
http://sysoev.ru/en/




More information about the nginx mailing list