redirect - Haproxy 重定向过多
问题描述
我想将土耳其以外的流量路由到另一个域,我将 acl 写入 haproxy,因此在土耳其它按计划工作,但在土耳其以外的流量重定向但显示的重定向太多。我在这个配置中缺少什么。我的流量来自 Cloudflare
acl acl_tr req.hdr(CF-IPCountry) eq "TR"
acl test_hname hdr(host) -m end lbtest.test.com
acl test_de hdr(host) -m end lbde.test.com
use_backend test_backends if acl_tr test_hname
redirect code 302 prefix https://lbde.test.com unless acl_tr
use_backend test_backends if test_de
解决方案
If someone outside of Turkey accesses your site, they might get redirected once to https://lbde.test.com
from your redirect rule. Assuming this hostname points to the same HAProxy instance, it will run into the very same redirect rule again, resulting in the same redirect to be sent.
To resolve this, you might want to leverage the test_de
ACL there to not perform the redirect if the user is already requesting the lbde.test.com
host:
redirect code 302 prefix https://lbde.test.com unless acl_tr || test_de
Finally, please make sure that you understand the order of rule evaluation in HAProxy. Although you have written your redirect
rule after your first use_backend
rule, it will still be evaluated before any use_backend
rules.
推荐阅读
- prolog - 如何在递归Prolog中将数据插入列表
- javascript - TensorFlow.JS 整数乘法结果十进制数
- android - Android 构建错误 - 取决于未定义的模块
- javascript - 为什么我的 discord.js 机器人会回复自己,即使我签了支票?
- java - 在 Java 中,在 Android 上将 2D pojo 数组序列化为 json
- java - Aapt2Exception:Android资源编译失败
- java - 如何使用retrofit2接收Json数组(“结果”)
- python - 没有表达式的Python while循环
- javascript - javascript循环的分层响应
- asp.net-core - How to use AbpSession?