Strip port number

Mark E mark at simplercomputing.net
Tue Dec 6 05:32:28 CET 2011


Hi,

I'm testing Varnish and have it on 6081. Apache is on port 80.

So in the browser I use http://site:6081 (where "site" is my actual 
domain name) to land on the home page. But the home page is not loading, 
Apache acts like it doesn't recognize the domain at all and returns the 
default Apache page that would be returned when a domain isn't recognized.

So, I think maybe what's happening is that Varnish is passing the port 
in the host header - e.g.  mysite:6081

In varnishlog I can see these lines:

-----------------
    12 RxRequest    c GET
    12 RxURL        c /
    12 RxProtocol   c HTTP/1.1
    12 RxHeader     c Host: site:6081
------------------

I have a line in vcl_recv like this that tries to strip the port number 
off the host header:

set req.http.Host = regsub(req.http.host, ":[0-9]+", "");

But that doesn't seem to remedy the problem. So I changed it to this 
thinking maybe the regex isn't right:

set req.http.Host = "site"

And even that doesn't work. Apache still returns it's default page 
instead of the domain's home page.

"varnishlog -V" shows "varnish-2.1.3 SVN" so I assume it's Varnish v2.1.3

Anyone know how I can get vcl to work right to load the domain's home 
page so I can get on with testing?

Mark




More information about the varnish-misc mailing list