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

2 servers, 1 public IP - Redirect subdomain internally

· 52CE 我爱测

I have 2 SSL web servers and 1 public IP address. I own a TLD (example.com), what I'd like to do is redirect server1.example.com to internal server A and server2.example.com to internal server B. How would I go about doing this? …

问题原文

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

I have 2 SSL web servers and 1 public IP address.

I own a TLD (example.com), what I'd like to do is redirect server1.example.com to internal server A and server2.example.com to internal server B.

How would I go about doing this? The webservers are not IIS or Apache, but they are management web applications using ports 443.

社区高分解答

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

You should use a reverse proxy (e.g. HAProxy, nginx, squid...) in front of those two servers. Bind public IP address to the proxy frontend and then use SSL SNI extension to route the traffic by the domain name to the backend servers.

HAProxy example (https://www.haproxy.com/blog/enhanced-ssl-load-balancing-with-server-name-indication-sni-tls-extension/):

# Adjust the timeout to your needs
defaults
  timeout client 30s
  timeout server 30s
  timeout connect 5s

# Single VIP 
frontend ft_ssl_vip
  bind 10.0.0.10:443
  mode tcp

  tcp-request inspect-delay 5s
  tcp-request content accept if { req_ssl_hello_type 1 }

  default_backend bk_ssl_default

# Using SNI to take routing decision
backend bk_ssl_default
  mode tcp

  acl application_1 req_ssl_sni -i application1.domain.com
  acl application_2 req_ssl_sni -i application2.domain.com

  use-server server1 if application_1
  use-server server2 if application_2
  use-server server3 if !application_1 !application_2

  option ssl-hello-chk
  server server1 10.0.0.11:443 check
  server server2 10.0.0.12:443 check
  server server3 10.0.0.13:443 check

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

资料来源与适用范围

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

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

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