Internal redirecition with dynamic backend (fetch 302 and return content)

2009-04-22 Thread Augustin Amann
Hi,

I'm looking for a reverse-proxy system with internal redirection, and I 
wonder if varnish can do the job.
I need the reverse proxy to act as a User-Agent with 302, and fetch 
content instead of returning 302 to the client,
to mimic 303 with 302 I think.


1) RP do GET to the backend
2) backend reply a 302 to another server
3) RP do a GET to this new location
4) RP return content and store it.

Maybe i can use restart, like [1].
I have no idea where the new location (gived by 302) is, this could be a 
problem for a reverse proxy !
So I think it's not realy the varnish way to deal with dynamic 
backend, but vcl is powerfull,
and if I can define backend host and url on the fly, it could save my day !

Or if there is another way, that's fine to me ...


Best regards,

Augustin.


[1] http://varnish.projects.linpro.no/ticket/411


___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Internal redirecition with dynamic backend (fetch 302 and return content)

2009-04-22 Thread Kristian Lyngstol
On Wed, Apr 22, 2009 at 08:41:58AM +0200, Augustin Amann wrote:
 1) RP do GET to the backend
 2) backend reply a 302 to another server
 3) RP do a GET to this new location
 4) RP return content and store it.
 
 Maybe i can use restart, like [1].
 I have no idea where the new location (gived by 302) is, this could be a 
 problem for a reverse proxy !
 So I think it's not realy the varnish way to deal with dynamic 
 backend, but vcl is powerfull,
 and if I can define backend host and url on the fly, it could save my day !

In vcl_fetch:

if (obj.status == 302) {
set req.url = obj.http.Location;
restart;
}

The normal routines in vcl_recv will have to determine which backend to use
based on the new req.url. This will have to be pre-defined backends, so no
random redirects I'm afraid.

-- 
Kristian Lyngstøl
Redpill Linpro AS
Tlf: +47 21544179
Mob: +47 99014497


pgp1tWetzNmtQ.pgp
Description: PGP signature
___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc


Re: Internal redirecition with dynamic backend (fetch 302 and return content)

2009-04-22 Thread Augustin Amann
Kristian Lyngstol a écrit :
 On Wed, Apr 22, 2009 at 08:41:58AM +0200, Augustin Amann wrote:
   
 1) RP do GET to the backend
 2) backend reply a 302 to another server
 3) RP do a GET to this new location
 4) RP return content and store it.

 Maybe i can use restart, like [1].
 I have no idea where the new location (gived by 302) is, this could be a 
 problem for a reverse proxy !
 So I think it's not realy the varnish way to deal with dynamic 
 backend, but vcl is powerfull,
 and if I can define backend host and url on the fly, it could save my day !
 

 In vcl_fetch:

 if (obj.status == 302) {
   set req.url = obj.http.Location;
   restart;
 }

 The normal routines in vcl_recv will have to determine which backend to use
 based on the new req.url. This will have to be pre-defined backends, so no
 random redirects I'm afraid.

   
Hi Kristian,
Thank you for your reponse. That's what I supected ...

For my needs, I combined squid to varnish, like this:

# Varnish VCL:

backend squid {
.host = 127.0.0.1;
.port = 3128;
}

sub vcl_fetch {
if (obj.status == 302 || obj.status == 301) {
#set req.backend = squid;
set req.url = obj.http.Location;
restart;
}
}

# squid.conf
http_port 3128 transparent

It works like a charm ... :)

Best Regards,
 
Augustin.

___
varnish-misc mailing list
varnish-misc@projects.linpro.no
http://projects.linpro.no/mailman/listinfo/varnish-misc