varnish / docker-varnish

Official docker image
https://hub.docker.com/_/varnish
81 stars 33 forks source link

Host header altered in default.vcl #75

Open lpaolini opened 2 weeks ago

lpaolini commented 2 weeks ago

I understand Varnish is supposed to be transparent, so why is the original Host request header replaced with backend's host:port in default configuration (default.vcl, lines 37-42)?

gquintard commented 2 weeks ago

Hi @lpaolini !

I understand Varnish is supposed to be transparent

What gave you that idea? :-)

TL;DR: it caters to the most common case for beginners.

As the default.vcl is really an entry-level solution so that new users don't have to write code to plug into their origin. From experience, users tend to discover the solution locally and just visit http://127.0.0.1, so aligning the host header with the host name prevents a bunch of issues where the origin returns a 400 or 404.

That being said, there's a case to be made about allowing a different host header with an environment variable, and I'm very happy to review PRs coming my way.

As always, I'm open to counter-arguments, I might very well have missed a factor in this discussion