【问题标题】:Reduce duplication in haproxy acl with multiple frontend sections使用多个前端部分减少 haproxy acl 中的重复
【发布时间】:2012-08-15 05:43:21
【问题描述】:

我正在使用 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

http-in 和 https-in 有不同的端口,https-in 必须 sepcify accept-proxy 以便 stunnel 可以使用代理协议将用户的原始 IP 传递给它。但除此之外,它们是相同的,并且应该始终相同。有没有办法减少这种重复? (haproxy 1.5-dev)

【问题讨论】:

  • FWIW,您可以使用 stunnel 的选项通过 X-Forwarded-for HTTP 标头发送 IP 地址。
  • stunnel 是一款了不起的软件,但为什么不在 HAproxy 中简单地终止 SSL 呢?太棒了!

标签: haproxy stunnel


【解决方案1】:

您可以简单地将前端中的一个 http 绑定到两者。

frontend http-in
  bind *:80
  bind 0.0.0.0:443 transparent

【讨论】:

    【解决方案2】:

    不幸的是,haproxy 手册 (http://haproxy.1wt.eu/download/1.5/doc/configuration.txt) 坚持只能在前端、侦听和后端部分定义 acl。

    如果 https 和 http 前端相同,您可以在一个前端定义几个绑定语句。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多