【发布时间】:2017-11-10 03:46:51
【问题描述】:
我已经在谷歌上搜索了几个小时,但没有找到必须简单的东西。
我正在使用 haproxy 1.7 并尝试将所有流量从一个域重定向到另一个“登录页面”并部分成功。我可以得到一个基本的重定向来工作,但是如果有人使用书签链接,他们会得到一个 404,因为新域上不存在 URL。
domain1.com/foo 或 domain1.com/bar/baz/whatever 都需要重定向到 domain2.com/landing 我在任何示例中都找不到关于如何执行此操作的 acl。我知道在 reidrect 之前它必须是某种重写规则,但我不能让一个工作。
这是我尝试过的一些设置:
# reqrep ^([^\ ]*)\ /(.*) \1\ /\2 if domain1_host
# redirect location https://domain2.com/landing code 301 prefix /landing drop-query if domain1_host
# http-request replace-header X-REWRITE ^/.*?$ /\1 if domain1_host
# reqrep ^([^\ ]*\ /)(.*) \1landing\2 if domain1_host
# reqrep ^([^\ ]*\ /)[/]?(.*) \1\2 if domain1_host
# reqrep ^([^\ ]*)\ /(.*) \1\ /\2 if domain1_host
# redirect prefix https://domain2.com/landing code 301 if domain1_host
redirect scheme https://domain2.com/landing code 301 if domain1_host
如果有人对我错过的内容有一些建议,我真的很感激一些方向。
【问题讨论】:
标签: haproxy