I have several internal sites, which I would like to reach by inserting a url with varnish. For example, if typed
http://www.example.com/serv1/--->http://192.168.0.1/application1
http://www.example.com/serv2/--->http://192.168.0.1/application2
At the moment, however, I do not understand how to configure varnish. My current configuration is as follows: default.vlc
vcl 4.0;
backend vm1 {
.host = "www.example.com";
.port = "81";
.connect_timeout = 6000s;
.first_byte_timeout = 6000s;
.between_bytes_timeout = 6000s;
}
backend serv1 {
.host = "192.168.0.1";
.port = "80";
.connect_timeout = 6000s;
.first_byte_timeout = 6000s;
.between_bytes_timeout = 6000s;
}
backend serv2 {
.host = "192.168.0.3";
.port = "80";
.connect_timeout = 6000s;
.first_byte_timeout = 6000s;
.between_bytes_timeout = 6000s;
}
sub vcl_recv {
if (req.url == "^/serv1/*$") {
set req.url = regsub(req.url, "^/serv1/*$","/application1");
set req.backend_hint = serv1;
} else {
set req.backend_hint = vm1;
}
if (req.url == "^/serv2/*$") {
set req.url = regsub(req.url, "^/serv1/*$","/application2");
set req.backend_hint = serv2;
} else {
set req.backend_hint = vm1;
}
}