vmod-named does not support host header with port

Dridi Boukelmoune dridi at varni.sh
Wed Apr 27 08:43:43 CEST 2016


Hello Daniel,

> with varnish 3.0 we use the dns director to look up the requested
> host header and redirect it back to our loadbalancer on the same IP
> as the request came in, but port 81 where our webserver is running.
>
> Curretly we are in the process of migrating to varnish 4.1.

I am very happy to see that vmod-named is helping you getting away
from Varnish 3. However, bugs should be reported on github [1]
instead. If you don't have or don't want a github account, let's keep
the discussion here.

> AFAIR, the DNS director has been removed from varnish4 core,
> because it did not support IPv6 properly.

I'm not sure that's the reason. I wasn't following the project as
closely as today but I think it has to do with directors being moved
outside of VCL, and the fact that the DNS director relied on the VCL
compilation phase to generate backends.

> After patching configure.ac file of libvmod-named with
> https://github.com/varnish/libvmod-example/commit/ad96d3b
> it even compiled under CentOS 7.2.

I'm working on improving the build system for VMOD authors, could you
please save me some work and try to build this branch [2] on your
platform?

> Unfortunately, vmod named seems to obtain the hostname for the DNS
> lookup directly from the req.http.host or bereq.http.host header,

I still haven't decided how to obtain the host header, I really need
to find my varnish 3 copy in my attic to see how it used to work in ye
olde times.

> but if the http user agent sends the following request header:
>
> Host: www.example.org:80
>
> The vmod named seems to be unable to look it up and the backend
> fetch will fail, if you provide a port number in the host header:
snip
> What would you recommend to support Host Headers including port numbers?
>
> Should I write some regsub() VCL to extract the hostname from req.http.host
> or bereq.http.host and pass it to the director, or should the source code
> of libvmod-named be changed to support RFC 2616 Host Headers with ports?

You may also notice that the v3 dns director has a prefix that can
automagically be prepended (or appended if you read domain names from
right to left=) but vmod-named doesn't do anything like that.

This is the kind of things that can be done in VCL, so I'm leaning
towards not implementing anything that can be done trivially in VCL.
Because I don't even need to tag a release version for people to
expect current master to stay backward compatible. And I'd like to
avoid breaking everyone's setup too often :)

That being said, I usually don't allow port numbers in host headers,
because by default it is part of the hash. For two clients making the
same request, with and without :80 in the host header may insert
duplicate entries in the cache. So when I'm the one writing the VCL,
:80 doesn't survive vcl_recv{} ;)

Cheers,
Dridi

[1] https://github.com/Dridi/libvmod-named/issues
[2] https://github.com/Dridi/varnish-modules/tree/feature/build



More information about the varnish-misc mailing list