r778 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
Dag-Erling Smørgrav
des at linpro.no
Wed Aug 9 13:36:05 CEST 2006
des at projects.linpro.no writes:
> Log:
> Add support for using separate backends for separate virtual hosts:
>
> - remove the obj.backend variable, which is not connected to anything.
> - define a req.backend variable and implement l/r functions for it
> - complete / correct support for setting / comparing backend values
With this patch, I have successfully proxied VG and Aftenposten
through the same Varnish instance using the following VCL code:
> backend vg {
> set backend.host = "leonora.vg.no";
> set backend.port = "80";
> }
>
> backend tanta {
> set backend.host = "80.91.37.210"; /* www.aftenposten.no */
> set backend.port = "80";
> }
>
> sub vcl_recv {
> if (req.http.host ~ "^(www\\.)?vg\\.no$") {
> /* set req.http.host = "www.vg.no"; */
> set req.backend = vg;
> } elsif (req.http.host ~ "^(www\\.)?aftenposten\\.no$") {
> /* set req.http.host = "www.aftenposten.no"; */
> set req.backend = tanta;
> } else {
> error 404;
> }
> }
Note that this only works if the client provides a valid Host: header.
What I want to do in the long run is:
- define HTTP_HDR_HOST and the corresponding req.host variable to be
used instead of req.http.host.
- add code to cache_http.c to dissect and normalize the request URL,
and set the initial value of req.host based on the host part of the
request URL and / or the Host: header
- make req.host and req.url writable so vcl_recv can perform further
normalization if needed (e.g. rewrite vg.no to www.vg.no)
DES
--
Dag-Erling Smørgrav
Senior Software Developer
Linpro AS - www.linpro.no
More information about the varnish-dev
mailing list