我使用 haproxy 和 stunnel 处理 SSL(并使用代理模式来保留 haproxy 的原始 IP)。
我有几个 acl 测试,根据域、标头或路径重定向到不同的后端。
问题是,无论您是通过 http 还是 https 进入,这些都是相同的,但我必须在配置中复制它们。有什么办法可以减少重复吗?
这是一个示例配置:
global
user haproxy
group haproxy
#etc...
frontend http-in
bind *:80
acl files_path path_beg /files/
acl beta_host hdr_beg(host) -i beta.
use_backend files if files_path
use backend beta_host
default_backend appservers
frontend https-in
bind *:442 accept-proxy
acl files_path path_beg /files/
acl beta_host hdr_beg(host) -i beta.
use_backend files if files_path
use backend beta_host
default_backend appservers
backend appservers
balance roundrobin
option forwardfor
server appserver_1 localhost:8080 weight 1
server appserver_2 192.168.1.101:8080 weight 1
backend files
balance roundrobin
option forwardfor
server file1 192.168.1.102 weight 1
server file2 192.168.1.103 weight 1
backend beta
balance roundrobin
server beta1 192.168.1.104 weight 1
Run Code Online (Sandbox Code Playgroud)
http-in和https-in有不同的端口,https-in必须指定accept-proxy,以便stunnel可以使用代理协议将用户的原始IP传递给它。但除此之外,它们是相同的,并且应该始终相同。有什么办法可以减少这种重复吗?(haproxy 1.5-dev)
您可以简单地将前端的一个 http 绑定到两者。
frontend http-in
bind *:80
bind 0.0.0.0:443 transparent
Run Code Online (Sandbox Code Playgroud)
不幸的是,haproxy手册(http://haproxy.1wt.eu/download/1.5/doc/configuration.txt)仍然规定acl只能在前端、监听和后端部分定义。
如果 https 和 http 前端相同,您可以在一个前端中定义几个绑定语句。
| 归档时间: |
|
| 查看次数: |
12886 次 |
| 最近记录: |