大网数据广告活动
服务器运维问答

HAProxy redirect multiple domain

· 52CE 我爱测

I have only one public IP address, and three Web server in LAN . I want to redirect the traffic from WAN to the Web server like this, must support SSL/TLS traffic redirect: https://www.example.com (A Record)===> 1.1.1.1(Public IP…

问题原文

原帖链接 · Bobylive · CC BY-SA 3.0

I have only one public IP address, and three Web server in LAN. I want to redirect the traffic from WAN to the Web server like this, must support SSL/TLS traffic redirect:

https://www.example.com (A Record)===> 1.1.1.1(Public IP) ===> 192.168.1.1(Web 1)

https://www.example.net (A Record)===> 1.1.1.1(Public IP) ===> 192.168.1.2(Web 2)

Can HAProxy finish this job?

社区高分解答

原帖链接 · Jeff W. · CC BY-SA 3.0

You can route to different backends for multiple FQDNs as long as you have the cert/key for the sites. HA proxy needs to be able to decrypt the traffic and read the host header, unless you want to attempt it with TCP forwarding, but you lose the ability to do persistence. your certificate files should be in PEM format.

 frontend https--in
  bind 1.1.1.1:443 ssl crt /etc/haproxy/certs
  mode http
  option httplog
  use_backend bk_1 if { hdr_dom(host) -i www.example.com }     { dst_port 443 }
  use_backend bk_2 if { hdr_dom(host) -i apps.example.com }    { dst_port 443 }
  use_backend bk_3 if { hdr_dom(host) -i www.otherdomain.com } { dst_port 443 }

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。