Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Misc

req.url in vcl_recv

 

 

Varnish misc RSS feed   Index | Next | Previous | View Threaded


Jeff.Stroomer at disney

Oct 11, 2011, 9:01 PM

Post #1 of 3 (557 views)
Permalink
req.url in vcl_recv

Varnish folks,

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.

Thanks,

Jeff


varnish at mm

Oct 12, 2011, 2:01 AM

Post #2 of 3 (533 views)
Permalink
Re: req.url in vcl_recv [In reply to]

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.

_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


lampe at hauke-lampe

Oct 12, 2011, 3:21 AM

Post #3 of 3 (538 views)
Permalink
Re: req.url in vcl_recv [In reply to]

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.
Attachments: signature.asc (0.19 KB)

Varnish misc RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.