Keep URL after rewriting
Rangel, Raul
Raul.Rangel at disney.com
Tue May 7 16:12:49 CEST 2013
I'm going to make the assumption that your webapp is writing absolute urls. I'm also going to make the assumption that it is using the Host header to write those urls. This is why your gusts never navigate back to the same domain. I see two potential options.
1) Configure your webapp not to write full urls.
2) Some web frameworks support the X-Forwarded-Host header. So you could set that header before you do any manipulations to it.
i.e)
set req.http.X-Forwarded-Host = req.http.host;
Raul
-----Original Message-----
From: varnish-misc-bounces at varnish-cache.org [mailto:varnish-misc-bounces at varnish-cache.org] On Behalf Of Hauke
Sent: Tuesday, May 07, 2013 6:25 AM
To: varnish-misc at varnish-cache.org
Subject: Keep URL after rewriting
Hi there,
i think I've got a fallacy at the moment.
After rewriting my URLs with Varnish I want to keep the origin URL given by a client.
We want to use our domain with some followed seperators, e.g.
www.example.com/corporate should point to a specific webapp, www.example.com/service should point to another webapp and so on.
The backend servers listen to some internal names like corporate- stag.example.local.
Here is my current Varnish config:
backend web1 {
.host="10.7.138.21";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}
backend web2 {
.host="10.7.136.61";
.probe = {
.url = "/";
.interval = 5s;
.timeout = 1 s;
.window = 5;
.threshold = 3;
}
}
director example round-robin {
{
.backend = web1;
}
{
.backend = web2;
}
}
sub vcl_recv {
set req.backend = example;
set req.http.host = regsub(req.http.host, "^www\.", "");
if (req.http.host ~ "example.com" && req.url ~ "^/corporate") {
set req.http.host = "corporate-stag.example.local";
set req.url = regsub(req.url, "corporate", "");
}
if (req.http.host ~ "example.com" && req.url ~ "^/service") {
set req.http.host = "service-stag.example.local";
set req.url = regsub(req.url, "service", "");
}
}
If I hit _www.example.com/corporate_ in my browser, I get the correct webapp.
But if I navigate, the hyperlinks are all pointed to _corporate- stag.example.local_ and they never pass Varnish again.
Where is my mistake?
--
Best regards,
Hauke
_______________________________________________
varnish-misc mailing list
varnish-misc at varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
More information about the varnish-misc
mailing list