Keep URL after rewriting
Hauke
mailman at haukebruno.de
Tue May 7 14:25:16 CEST 2013
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
More information about the varnish-misc
mailing list