Strip port number
Michael Alger
varnish at mm.quex.org
Tue Dec 6 05:54:55 CET 2011
On Mon, Dec 05, 2011 at 09:32:28PM -0700, Mark E wrote:
>
> 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
> [...]
> I have a line in vcl_recv like this that tries to strip the port
> number off the host header:
> [...]
> 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.
>
> Anyone know how I can get vcl to work right to load the domain's
> home page so I can get on with testing?
Should be working, so I think something else is the issue. Here's some
things to consider off the top of my head. If none of them help, maybe
post your vcl_recv() function, anonymized if necessary.
- Are you sure your second attempt was fetched from the origin, and
not a cached result from earlier attempts?
- If you have any conditional logic in vcl_recv double-check you're
not returning before you overwrite the host header or something
along those lines.
- Double-check you're sending a host header it'll understand, e.g.
including or excluding the "www." in front as required.
- Is Varnish using the correct backend for that host?
- It might be worth watching the log output and seeing what headers
Varnish is sending in the request to the backend; and/or you could
modify your backend so the default page for unrecognised hosts is a
script that outputs the value of the host header it received, and
maybe also the date+time the response was generated.
More information about the varnish-misc
mailing list