首页 > 解决方案 > HA 代理 - 在同一域 ACL 上同时使用 HTTP 和 HTTPS

问题描述

我在多台主机上有一个有效的 HA-Proxy 转发请求 HTTPS。对于一台主机,HTTP 流量应保持为纯 HTTP

我知道重定向规则可以避免一个规则,但我不清楚我是否需​​要声明两个后端

现有代码

frontend HTTPIN
    bind localhost:80
    bind localhost:443 ssl crt-list /etc/haproxy/ssl/crt-list
    
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }

    redirect scheme https code 301 if !{ ssl_fc }
    
    acl host_HOST1 hdr(host) -i sub.domain.com
    
    use_backend HOST if host_HOST1
    
backend HOST
    server host_ip host_ip:443 check ssl check-ssl verify none
    http-check expect rstring ^200\ OK(.*)$

目标是让http://sub.domain.com到 host_ip:80 和https://sub.domain.com到 host_ip:443。

谢谢您的帮助!

标签: haproxy

解决方案


推荐阅读