【问题标题】:How can I redirect specific HTTPS request to a backend server using HAPROXY如何使用 HAPROXY 将特定的 HTTPS 请求重定向到后端服务器
【发布时间】:2018-03-16 14:59:53
【问题描述】:

我有一个 HTTPS 服务器,并希望根据 URL 将特定请求重定向到我的后端服务器。

【问题讨论】:

标签: haproxy


【解决方案1】:

应该这样做(对于 HTTP):

frontend http
    bind *:80
    acl mpd path_end -i .mpd
    acl test hdr(host) test.com www.test.com
    use_backend internal if test mpd

backend internal
    http-request set-path /path/folder%[path]
    # for older versions 
    # reqirep ^([^\ :]*)\ \/(.+\/)*(.*)\  \1\ /path/to/folder/\3
    server internal-1 internal:80 check

frontend 中的两个 ACL 选择正确的后端,http-request(旧版本为reqirep)命令会覆盖原始请求路径。

你可能需要调整它。

【讨论】:

  • 我做了以下配置: frontend http bind *:80 acl mpd path_end -i .mpd acl test hdr(host) test.usp.com test.usp.com use_backend internal if test mpd backend internal http- request set-path /vod/ server testirdeto.test.com 172.28.1.16:80 check
  • 但是我得到了错误:haproxy-systemd-wrapper:正在执行/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -Ds localhost haproxy -systemd-wrapper: [ALERT] 074/121802 (4532) : 解析 [/etc/haproxy/haproxy.cfg:108]: 'http-request' 需要 'allow', 'deny', 'auth', 'redirect' , 'tarpit', 'add-header', 'set-header', 'replace-header', 'replace-value', 'set-nice', 'set-tos', 'set-mark', 'set- log-level','add-acl','del-acl','del-map','set-map',但是得到了'set-path'。 localhost haproxy-systemd-wrapper:[ALERT] 074/121802 (4532):在配置文件中发现错误:/
  • 您使用的是哪个版本的 HAProxy? set-path 在 1.6 中引入。
  • HA-Proxy 版本 1.5.18 2016/05/10
  • 您可以改用reqirep。请参阅更新的回复。它替换了路径目录,例如/foo/bar/baz.ext/path/to/folder/baz.ext。根据需要进行调整。
猜你喜欢
  • 1970-01-01
  • 2018-11-10
  • 2017-10-01
  • 1970-01-01
  • 2019-02-28
  • 1970-01-01
  • 2016-03-13
  • 2014-12-28
  • 2021-01-31
相关资源
最近更新 更多