- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我曾尝试为我遇到的问题寻找类似的解决方案,但找不到任何东西。
我已经设置了一些 LXD 容器,一个是 HAProxy,它从主机的公共(public) IP 地址接收端口 80 流量。 HAProxy 然后根据域将流量发送到正确的容器。
我遇到的问题是,尽管我已经为 subdomain.example.com
设置了 domain_specific_subdomain
ACL 规则,但另一个 domain_root
ACL 规则优先。
容器:
问题:我怎样才能让裸域 example.com
和所有其他子域(例如 www.、dev. 等)转到此后端 backend_web1
除了 subdomain.example.com
应该转到:backend_web2
后端。
这是我的配置文件:
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
log global
mode http
option httplog
option dontlognull
option forwardfor
option http-server-close
timeout connect 5000
timeout client 50000
timeout server 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
# Frontend
frontend www_frontend
bind *:80 # Bind to port 80 (www) on the container
# Covers naked domain and all subdomains
acl domain_root hdr(host) -i example.com
# Specific sub-domain
acl domain_specific_subdomain hdr(host) -i subdomain.example.com
# Redirect the connection to the proper server cluster, depending on the match.
use_backend backend_web1 if domain_root
use_backend backend_web2 if domain_specific_subdomain
# Domain dependent containers
backend backend_web1
balance leastconn
# We set the X-Client-IP HTTP header. This is useful if we want the web server to know the real client IP.
http-request set-header X-Client-IP %[src]
# This backend, named here "backend_web1", directs to container "lxd-container-web1.lxd" (hostname).
server web1 lxd-container-web1:80 check
backend backend_web2
balance leastconn
http-request set-header X-Client-IP %[src]
server web2 lxd-container-web2.lxd:80 check
最佳答案
来自 haproxy 文档:
There may be as many "use_backend" rules as desired. All of these rules are evaluated in their declaration order, and the first one which matches will assign the backend.
因此,如果您切换 use_backend
行顺序,它应该可以工作。
# Redirect the connection to the proper server cluster, depending on the match.
use_backend backend_web2 if domain_specific_subdomain
use_backend backend_web1 if domain_root
或者更好的是,也许 default_backend
在这里会更好:
# Use backend_web2 if ACL matches
use_backend backend_web2 if domain_specific_subdomain
# Otherwise, default to backend_web1
default_backend backend_web1
关于linux - HAProxy 和 LXD 容器 - 基于裸域、特定子域和所有其他子域的路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49875318/
我只是看了一下HAproxy的源码来了解它是如何实现的,我看到了一个有趣的数据结构,叫做Elastic Binary Search tree .它似乎与二叉搜索树非常相似。但我想知道为负载均衡器选择这
我正在 AWS 上部署 NodeJS 应用程序。目前的结构是 ELB 1 个 HAProxy 实例 2+ 个运行 NodeJS 应用程序的 EC2 实例 Single HA Proxy 实例确保
更改配置文件时,我使用以下命令重启 HAProxy: /usr/local/sbin/haproxy -f /etc/haproxy.cfg -p /var/run/haproxy.pid -sf $
我有两个 HAProxy 实例。两个实例都启用了统计信息并且工作正常。 我正在尝试将两个实例的统计信息合并为一个,以便我可以使用单个 HAProxy 来查看前端/后端统计信息。我试图让两个 hapro
在重新启动 HAProxy 服务之前,有什么方法可以验证 HAProxy haproxy.cfg 文件吗?例如:较大的 haproxy.cfg 文件中可能存在小的拼写/语法错误。我搜索了多个论坛,但找
我希望在 HAProxy 中有一个限制规则,限制用户加载任何特定路径的速率,但我不知道在 HAProxy 中连接字符串的方法(至少在生成棍子 table 的 key )。所以我想要的是 tcp-req
我正在构建一个具有多个前端和后端的 haproxy 配置文件。它将有数百行长,我宁愿将其分成单独的文件,用于我想要负载平衡的每个不同网站。 HAProxy 是否提供从主 haproxy.cfg 文件链
我正在使用以下命令启动 HA 代理: sudo etc/init.d/haproxy start 我使用以下方法停止 HA 代理: sudo etc/init.d/haproxy stop 我如何为
我使用 haproxy 和 stunnel 处理 SSL(并使用代理模式来保留 haproxy 的原始 IP)。 我有几个 acl 测试,根据域、 header 或路径重定向到不同的后端。 问题是,无
我看到系统日志中弹出这些消息: Mar 10 12:51:35 db1 kernel: [5851729.958138] type=1400 audit(1457614295.823:2925931)
我在 haproxy.cfg 的默认部分有这个选项: option dontlog-normal option dontlognull 但是在日志文件中仍然有这种类型的日志行: localhost
我们使用以下方法将 URL 映射文件加载到 HAProxy 中: http-request redirect location %[capture.req.uri,map(/etc/haproxy/r
我目前正在重构我们在生产服务器上使用的 haproxy 配置,以从中央服务器转发 TCP 流量。目标是让一切都与 docker 容器一起工作,以帮助提高部署可靠性。 到目前为止一切都进展顺利,但现在我
我在我的 HAProxy 统计报告中看到 Sessions Curr、Max、Limit 均为 2000。 如何将最大和限制增加到 2000 以上? 最佳答案 使用maxconn Sets the m
我环顾四周,试图找到一个 HAProxy 匹配 SNI 通配符的示例,我的搜索提出了类似标题但与证书无关的问题。 具体来说,我需要使用 acme/letsencyrpt 为 dvsni 路由 nonc
我们有一个 haproxy 实例,我们的一个应用程序仅支持 TLSv1.0。当它尝试通过此 haproxy 连接时,它会因握手失败而失败。 如何在此 haproxy 实例上启用 TLSv1.0 支持。
如何构建HAPROXY配置文件来阻止特定HTTP方法的请求? 我们开始发现许多攻击使用我们的应用程序不支持的方法。我们宁愿拒绝负载均衡器的流量,也不愿让我们的应用程序陷入困境。 最佳答案 尝试将其放入
我使用 haproxy 1.6.4 作为 TCP(不是 HTTP)代理。我的客户正在发出 TCP 请求。他们不等待任何响应,他们只是发送数据并关闭连接。 当所有后端节点都关闭时,haproxy 的行为
我需要使用先前配置的 HAproxy v1.8 来管理服务器。更新到 v2.4 后,我注意到有关不再使用 regrep 的错误: [ALERT] (1574) : parsing [/etc/h
我们使用 HAProxy 将传入的 TCP 连接转发到使用原始 TCP 的单独服务器。我们看到的问题是客户端连接被接受然后关闭而不是立即被拒绝。由于我们启用了健康检查,HAProxy 有什么方法可以解
我是一名优秀的程序员,十分优秀!