docker-archive / dockercloud-haproxy

HAproxy image that autoreconfigures itself when used in Docker Cloud
https://cloud.docker.com/
651 stars 187 forks source link

[question] - using backends with multi secured and non secured domains #158

Closed dfanchon closed 7 years ago

dfanchon commented 7 years ago

Hi @tifayuki,

We are using haproxy in Dockercloud, with backends supporting both http and https domains (i.e VIRTUAL_HOST=http://domain1.com,https://domain1.com,http://domain2.com). ATM we can't use the force_ssl option because https redirection is set at backend level. Is there a chance to scope the redirection to the only domains declared with https scheme?

Thanks

tifayuki commented 7 years ago

@dfanchon I don't think it is easy to support such a use case. But you can manually specify another backend and make one of the domain point to the new backend.

For example, in your application, set VIRTUAL_HOST=http://domain1.com,https://domain1.com only. Add EXTRA_FRONTEND_SETTINGS_80=acl new_rule hdr(host) -i domain2.com, use_backend domain2 if new_rule. And use ADDITIONAL_BACKENDS to replicate the existing backend.

It is more like a ugly workaround, but generally speaking, it is better to let the proxy to terminate the SSL if possible. If not, use TCP instead of HTTP load balancing.