【问题标题】:Haproxy without backend没有后端的 Haproxy
【发布时间】:2020-02-28 18:39:23
【问题描述】:

是否可以在没有后端的情况下配置 HAProxy 但不会失败,因为我们只需要一个 HAProxy 来重定向 url

【问题讨论】:

标签: url redirect backend haproxy


【解决方案1】:

并非完全可能(或有意),但使用静态文件作为默认后端似乎可行:

...
frontend http-in
    bind *:8080
    http-request redirect location https://%[hdr(host),lower,map(/usr/local/etc/haproxy/redirect.map)]%[capture.req.uri] code 301 if { hdr(host),lower,map(/usr/local/etc/haproxy/redirect.map) -m found }
    default_backend kitchen-sink

backend kitchen-sink
    mode http
    errorfile 503 /usr/local/etc/haproxy/errors/kitchen-sink.http
...

kitchen-sink.http 包含:

HTTP/1.0 200 Found
Cache-Control: no-cache
Connection: close
Content-Type: text/plain

200 Found

redirect.map

# SOURCE -> TARGET
old.example.com new.example.com

【讨论】:

    猜你喜欢
    • 2022-10-13
    • 2014-08-27
    • 2016-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多