req.url in vcl_recv

Hauke Lampe lampe at hauke-lampe.de
Wed Oct 12 12:21:04 CEST 2011


Hi Jeff.

On 12.10.2011 06:01, Stroomer, Jeff wrote:

> I've seen plenty of example vcl code that seems to say req.url will
contain /a/b/c.
> But it looks like I'm actually getting the full URL, i.e.,
> http://xyz.com/a/b/c.

If you see that in each and every request, I'd suspect another reverse
proxy or load balancer at your end.

I see this request format, too, occasionally, but I haven't tried to
figure out which browsers/bot actually cause it.

I use this code in vcl_recv() to normalize the URL:

# fix "GET http://host/path" request
# extract Host: header and rewrite URL
if (req.url ~ "(?i)^https?://") {
	set req.http.Host = regsub(req.url, "(?i)^https?://([^/]*).*", "\1");
	set req.url = regsub(req.url, "(?i)^https?://[^/]*/?(.*)$", "/\1");
}

( http://cfg.openchaos.org/varnish/vcl/3.x/common/normalize_http.vcl )


Hauke.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <https://www.varnish-cache.org/lists/pipermail/varnish-misc/attachments/20111012/a6978033/attachment-0003.pgp>


More information about the varnish-misc mailing list