haproxy-将特定域/路径重定向到其他域

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

我需要从特定域/路径到具有相同路径的其他域的重定向请求,例如

domain.com/foo/everything-> example.com/foo/everything

我认为需要使用url_reg,但我不明白如何处理重定向,也许是这样吗?

acl redirect-foo   url_reg -i      ^domain.com\/foo\/*
http-request redirect code 301 location http://example.com/foo/ if redirect-foo

但是很明显这行不通,谢谢能帮助我的人

haproxy
1个回答
0
投票

您可以使用以下代码段


  acl host_match hdr(host) -i domain.com
  acl path_match path_beg  -i /foo/

  http-request redirect code 301 location http://example.com/%[capture.req.uri] if host_match path_match

Acl在文档和以下博客文章中进行了描述。

Using ACLs to form conditionsIntroduction to HAProxy ACLs

capture.req.uri的文档

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