Zope/plone cache rewrite rules?

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]

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]

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]

a lot of tnks for your help :smiley:

att: gap

Hi,

On Mon 31.12.2008 15:45, Alexis Torres Garnica wrote:

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

Tnks for your answer Aleksandar L., I was slow to respond because a problem in the squid configuration, Im trying this configuration based in your:

        location /ultimas/ {
                #proxy_pass http://132.247.1.32:8080/http/www.jornada.unam.mx/80/ultimas;
                #proxy_pass http://132.247.1.32:8080/http/${http_host}/80/ultimas;
                #proxy_pass http://132.247.1.32:8080/http/132.248.10.56/80/ultimas;
                #proxy_pass http://132.247.1.32:8080/http/impresa.jornada.com.mx/80/ultimas;
                #proxy_pass http://132.247.1.32:8080/http/www.jornada.unam.mx/ultimas;
                #proxy_pass http://132.247.1.32:8080/http/${http_host}/ultimas;
                #proxy_pass http://132.247.1.32:8080/http/132.248.10.56/ultimas;
                proxy_pass http://132.247.1.32:8080/http/impresa.jornada.com.mx/ultimas;
        }

in each case I just get this if I do http://impresa.jornada.com.mx:81/ultimas/

The requested URL could not be retrieved

While trying to retrieve the URL: http://denypool/denyme

The following error was encountered:

    Unable to determine IP address from host name for denypool

The dnsserver returned:

    Name Error: The domain name does not exist.

This means that:

 The cache was not able to resolve the hostname presented in the URL.
 Check if the address is correct.

Your cache administrator is [email protected].
Generated Fri, 04 Jan 2008 20:05:22 GMT by squidtest.jornada.unam.mx (squid/2.5.STABLE14)

last question Aleksandar, why do you removed the /80/ in the rule?

tnks for your help :D and nice week end for all guys =).


Aleksandar L. escribió:
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



Sorry but I can’t read this, due the fact I’am not a html-parser :wink:

Please can you resend it with text only :wink:

Thanks

Aleks

— full qoute to see how I see it.
On Fre 04.01.2008 14:08, Alexis Torres Garnica wrote:


http://132.247.1.32:8080/http/www.jornada.unam.mx/ultimas;

    Name Error: The domain name does not exist.
last question Aleksandar, why do you removed the /80/ in the rule?
Hi guys, I have problems porting this apache
RewriteRule ^/ultimas(.*)        
}