【发布时间】:2020-02-28 18:39:23
【问题描述】:
是否可以在没有后端的情况下配置 HAProxy 但不会失败,因为我们只需要一个 HAProxy 来重定向 url
【问题讨论】:
标签: url redirect backend haproxy
是否可以在没有后端的情况下配置 HAProxy 但不会失败,因为我们只需要一个 HAProxy 来重定向 url
【问题讨论】:
标签: url redirect backend haproxy
并非完全可能(或有意),但使用静态文件作为默认后端似乎可行:
...
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
【讨论】: