zope/plone cache rewrite rules?

Aleksandar Lazic al-nginx at none.at
Tue Jan 1 15:14:40 MSK 2008


Hi,

On Mon 31.12.2008 15:45, Alexis Torres Garnica wrote:
> Hi guys, I have problems porting this apache mod_rewrite rules to
> nginx rewrite rules, I have a zope server who talk with squid
> (configured like a reverse proxy), infront the squi we have apache2,
> the arch is this:
>
> people -> request -> apache -> squid -> zope
>
> we wanna replace apache with nginx, the actual apache rewrite rules
> are this for http://domain/ultimas:
>
>RewriteRule ^/ultimas(.*)/$
>        http://127.0.0.1:8080/http/%{SERVER_NAME}/80/ultimas$1 [L,P]
>RewriteRule ^/ultimas(.*) 
>         http://127.0.0.1:8080/http/%{SERVER_NAME}/80/ultimas$1 [L,P]

You need at least 0.6.18 so that you can use variales in proxy_pass.
You should take a look into 

http://wiki.codemongers.com/NginxHttpCoreModule#location
http://wiki.codemongers.com/NginxHttpProxyModule#proxy_pass

I would try this:

location ^/ultimas(.*) {

   proxy_pass http://127.0.0.1:8080/http/${http_host}/ultimas$1;

}

> This is for the virtual host called migarcion
>
>RewriteCond %{REQUEST_FILENAME}  .*jpg$|.*gif$|.*png$ [NC]
>RewriteCond %{HTTP_REFERER}  !^$
>RewriteCond %{HTTP_REFERER}  !migracion\.jornada\.unam\.mx [NC]
>RewriteRule ([0-9]{4})/([0-9]{2})/([0-9]{2})/?(.*) 
>   http://%{SERVER_NAME}/showpic.php?pic=$1/$2/$3/$4  [L]

http://wiki.codemongers.com/NginxHttpRefererModule

location ~* \.(gif|jpg|png)$ {

   valid_referers migracion.jornada.unam.mx;
   
   if ($invalid_referer){
     return 403;
   }

   if($request_uri ~ "([0-9]{4})/([0-9]{2})/([0-9]{2})/?(.*)" ){
     # for this I'am not sure
     proxy_pass http://${http_host}/showpic.php?pic=$1/$2/$3/$4;
   }
}

> This is for one virtual host called ciencias
>
> RewriteCond %{REQUEST_FILENAME}  .*jpg$|.*gif$|.*png$ [NC]
> RewriteCond %{HTTP_REFERER}  !^$
> RewriteCond %{HTTP_REFERER}  !ciencia\.jornada\.unam\.mx [NC]
> RewriteRule ([0-9]{4})/([0-9]{2})/([0-9]{2})/?(.*) 
> http://%{SERVER_NAME}/showpic.php?pic=$1/$2/$3/$4  [L]

Similar the the up one, only with diff referer host ;-).

Hth

Aleks





More information about the nginx mailing list