By Chris Kelly
How does one set up HAproxy for multiple domains, to multiple backends while passing through SSL? I would also be open to an nginx solution
Example in diagram for a better explanation:
backend_domain_a
domain-a.com-. .-> 123.123.123.123
| |
+-> haproxy -+
| | backend_domain_b
domain-b.com-' '-> 789.789.789.789
Note Each backend server will be issueing their own certificate. Hence the need for SSL passthrough.
I have this configuration, but doesn’t work for multiple reasons (the key one being the missing port number):
frontend www
bind *:80
bind *:443
option tcplog
acl host_domain_a hdr(host) -i domain-a.com
acl host_domain_b hdr(host) -i domain-b.com
use_backend backend_domain_a if host_domain_a
use_backend backend_domain_b if host_domain_b
backend backend_domain_a
server web_a 123.123.123.123 check
backend backend_domain_b
server web_b 789.789.789.789 check
In others words, I want Haxproxy to not terminate the SSL.
I initially wanted to do this with Nginx but apparently it can’t act as a non-terminating point while reading the host details (though might be available in future versions with ssl preread)
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You need to use HAProxy as a Level 4 load balancer. This means explicitly setting “mode tcp” under frontend, backend a, and backend b. See the HAProxy section of this guide for details except note that you are forwarding to two domains, not one.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.