HAProxy将一个URL重定向到另一个URL

问题描述 投票:0回答:1

我对HAProxy很陌生,我认为这是一个简单的用例:我想将请求重定向到我的KVM主机->来宾VM的URL。在我的情况下,重定向是针对运行HTTPS内容的多个VM。

示例:-HAProxy在KVM主机上运行(10.10.10.5-ansout.mine.local)-在KVM上运行的HTTPS来宾VM(172.10.10.5-ans.lab.local)

我如何从客户端(在KVM网络上)向'http://ansout.mine.local'发出请求,并将其重定向到'https://ans.lab.local'

似乎我需要在HAProxy中使用“ http-request redirect”功能,但仍然无法解决。任何人都可以就如何实现上述示例提供一些指导吗?提前非常感谢。

haproxy
1个回答
0
投票

我假设客户端随后应直接连接到ans.lab.local。

listen http-in
  bind :80

  log stdout format raw daemon
  mode http
  option httplog

  tcp-request inspect-delay 5s
  tcp-request content accept if HTTP

  timeout client   5s
  timeout connect 30s
  timeout server  30s

  http-request redirect code 301 location https://ans.lab.local if { hdr(host) -i ansout.mine.local }

如果您有几台要重定向的主机,请查看HAProxy Maps

© www.soinside.com 2019 - 2024. All rights reserved.