20 messages in ru.sysoev.nginxRe: Tricky Rewrite rules.
FromSent OnAttachments
Gustavo BarrónNov 18, 2007 8:53 am 
HonDev DeveloperNov 18, 2007 4:17 pm 
HonDev DeveloperNov 18, 2007 4:44 pm 
HonDev DeveloperNov 18, 2007 5:37 pm 
Gustavo BarrónNov 18, 2007 10:30 pm 
HoneNov 20, 2007 12:15 pm 
HoneNov 20, 2007 1:30 pm 
Gustavo BarrónNov 20, 2007 2:15 pm 
HoneNov 20, 2007 8:29 pm 
HoneNov 20, 2007 8:46 pm 
HoneNov 21, 2007 6:01 pm 
Gustavo BarrónNov 21, 2007 6:50 pm 
HonDev DeveloperNov 22, 2007 3:46 am 
HonDev DeveloperNov 22, 2007 4:05 am 
HonDev DeveloperNov 22, 2007 4:23 am 
HonDev DeveloperNov 22, 2007 3:17 pm 
HonDev DeveloperNov 26, 2007 2:41 am 
HonDev DeveloperNov 26, 2007 2:44 am 
HonDev DeveloperApr 24, 2008 12:26 am 
HonDev DeveloperApr 24, 2008 1:41 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Tricky Rewrite rules.Actions...
From:Gustavo Barrón (list@public.gmane.org)
Date:Nov 21, 2007 6:50:48 pm
List:ru.sysoev.nginx

Hone wrote:

Maybe another way to do it would be to set up a second backend instance of nginx on another port which serves all the php dynamic.

1. http client makes request 2. if static is required and available the front nginx serves it 3. if no static is found the request gets proxied to the second nginx server with php fastcgi

Your 2nd Nginx would have your normal rewrites and the fastcgi php set up and your first file could look like this. I haven't had time to test this.

upstream 2ndNginx { server 127.0.0.1:82; }

server { listen 80; server_name supercachestatic.com; location / {

root /var/www/mydomain.com/htdocs; index index.html;

if ($query_string !~ ".*s=.*") { rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html; }

if ($http_cookie !~ "^.*comment_author_.*$" ) { rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html; }

if ($http_cookie !~ "^.*wordpressuser.*$" ) { rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html; }

if ($http_cookie !~ "^.*wp-postpass_.*$" ) { rewrite ^(.*) /wp-content/cache/supercache/$http_host/$1index.html break; }

error_page 404 = @2ndNginx;

location @2ndNginx { proxy_pass http://2ndNginx;

I was thinking that, but apparently, after a couple of tries today, it seems, the problem resides partially on wp-super-cache, carrying on a bug from wp-cache with php 5.2.x and fastgi. I will check it later today in order to see How can be fixed that.

But actually is a good idea. I was thinking on something similar after reviewing a RoR site this morning. I will check it later as an alternative. Because my fix for wp-cache/wp-super-cache requires patching :/