reverse-proxy - 将 Nginx 配置转换为 Haproxy
问题描述
我正在尝试将我的反向代理从 Nginx 迁移到 Haproxy,以使用它的健康检查、地图和监控功能。
HAProxy 配置似乎不像 Nginx 那样简单。有人可以帮我将以下 nginx 规则转换为 haproxy 配置。
location = / {
proxy_set_header X-Forwarded-Host $server_name;
proxy_pass https://myapp.azurewebsites.net;
}
location /test {
proxy_pass https://myapp.azurewebsites.net;
}
location /test/ {
proxy_pass https://myapp.azurewebsites.net;
}
所以我对所有规则都有相同的后端。我在 HAProxy 配置下使用,但它仅适用于/test/
但不适用于/test
acl is_domain hdr(host) -i www.domain.com
use_backend be_test if is_domain { path -i / } || { path -i -m beg /test}
backend be_test
mode http
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request replace-header Host .* myapp.azurewebsites.net
server srv01 myapp.azurewebsites.net:443 weight 1 maxconn 100 check ssl verify none
解决方案
日志说什么?
不确定replace-header Host
是否需要,因为您的 Azure 网站应作为 VirtualHost 回复 www.domain.com。
推荐阅读
- python - 可编辑依赖项中的 Python 模块名称冲突
- html - 通过类名获取网页数据
- c# - 如何创建只有样式没有类或 id 的动态 xpath
- google-cloud-platform - Google Cloud HTTP 负载均衡器是否支持 gRPC?
- mysql - Unsastistified 依赖项:创建名称为“entityManagerFactory”的 bean 时出错
- layout - Blazor .NET Core 3.0 - cshtml 页面可以使用 MainLayout.razor
- javascript - 隐藏子元素后如何更正元素的高度?
- javascript - 如何使用谷歌分析动态跟踪链接点击?
- mysql - 如何为gorm组织多个外键
- docker - 无法获得隶属关系'org3.department1 :: scode:404,代码:63,msg:无法获得隶属关系:sql:结果集中没有行