req.url in vcl_recv

Michael Alger varnish at mm.quex.org
Wed Oct 12 11:01:15 CEST 2011


On Tue, Oct 11, 2011 at 09:01:40PM -0700, Stroomer, Jeff wrote:
> Suppose the incoming URL in Varnish is http://xyz.com/a/b/c.  What
> should I expect to see as the value for req.url inside vcl_recv?
> 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.   Is this correct?  If so, why to
> all the examples seems to say the http://xyz.c/om/ prefix will be
> stripped off?  If it  makes a difference, I'm running Varnish 3.0.1
> on Ubuntu 11.04.

req.url will contain whatever the requesting client sent in the
request after the method, so if the browser sent an absolute URI like
  GET http://xyz.com/a/b/c HTTP/1.1
then req.url will be "http://xyz.com/a/b/c".

If the browser sent just the path, like:
  GET /a/b/c HTTP/1.1
then req.url will be "/a/b/c".

Clients will normally only send the full URL if they think they're
talking to a proxy server (i.e. they've been configured to use a proxy
server) as that's the RFC-mandated behaviour. Many web servers will
correctly handle both forms, but when speaking to an origin server the
client is supposed to just send the request path, not the full URI
along with protocol specification.

What browser are you using? Do you have any other proxies / load
balancers in front of Varnish that can be configured to act as if
they're talking to a backend rather than a proxy? As far as the HTTP
protocol is concerned, Varnish is more akin to an origin server than a
proxy, and anything talking to it should be treating it as such.




More information about the varnish-misc mailing list