1

As the title says, I'm looking for the practical difference (and potential pitfalls) of using $http_host instead of the $host variable in the proxy_set_header settings in nginx

Of course I have already read the answer to this question What's the difference of $host and $http_host in Nginx. But apart from $host removing the port and making lower case, that doesn't really explain in what scenarios that would affect my application, like when will the "HTTP_HOST is absent or is an empty value"? Is it when the user are using an older browser or when he/she passes through another proxy at the way?

(I'm using nginx to route traffic to a python flask backend application (also using flask-socket.io)

Community
  • 1
  • 1
Markus
  • 3,297
  • 4
  • 31
  • 52

1 Answers1

1

The practical difference is that $host provides a wider compatibility, particularly with obsolete versions of the HTTP protocol (for example RFC 2068).

$host is preferred over $http_host for public facing applications, as it is the least restrictive on client compatibility. Whereas $http_host might be useful in applications where strict protocol compliance would be beneficial.

Community
  • 1
  • 1
Richard Smith
  • 45,711
  • 6
  • 82
  • 81
  • 2
    Just a couple of examples would be very appreciated. Like when would I be subjected to a obsolete version of the HTTP protocol? It it in an old browser? Or could it be if the traffic is routed through an unfortunate route? Or is it if my server application is of an old version? – Markus Oct 11 '16 at 14:49