mesosphere / marathon-lb

Marathon-lb is a service discovery & load balancing tool for DC/OS
Apache License 2.0
450 stars 300 forks source link

Proxypass rewrite Host header #658

Open alsyia opened 5 years ago

alsyia commented 5 years ago

Hi,

We have an application that need to be accessible from two DNS and for which requests' URLs should be rewritten.

We configured marathon-lb as follow: HAPROXY_0_VHOST=dns1.com,dns2.com HAPROXY_0_PATH=/api HAPROXY_0_HTTP_BACKEND_PROXYPASS_PATH=/api

We see requests arriving to the application with a Host header equal to dns1.com,dns2.com (which breaks some stuff in our own code). Skimming through the code, I think the issue lies in the default HTTP_BACKEND_PROXYPASS template which is:

http-request set-header Host {hostname}
reqirep  "^([^ :]*)\ {proxypath}(.*)" "\\1\ /\\2"

This takes the app hostname (the content of HAPROXY_0_VHOST) and put it directly in the Host header, regardless of the original value.

I can override this default template, but I wonder why it has been written this way. What is the point of rewriting the Host header to the value it should already have? Am I missing something?

Please note it works well when HAPROXY_0_VHOST contains a single entry.

Thanks :)