`
sillycat
  • 浏览: 2564749 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

HAProxy ACL Regex Rules

 
阅读更多
HAProxy ACL Regex Rules
Official Website about append-slash
http://cbonte.github.io/haproxy-dconv/1.6/configuration.html#4.2-redirect%20scheme
Recently, there is an issue about URL proxy
https://www.sillycat.com/blog/free-google-ads-adwords-coupon-codes/
From server side, both URLs are working
https://www.sillycat.com/blog/free-google-ads-adwords-coupon-codes
https://www.sillycat.com/blog/free-google-ads-adwords-coupon-codes/
But for google SEO, they will index 2 times which my boss thinks it is not good.
One option is to remove the blash in following configuration
frontend webapp
    bind *:80
    bind *:443
    http-request redirect code 301 location http://%[hdr(host)]%[url,regsub(/$,)] if { path_end / } { path_len gt 1 }
But that breaks some of the blog pages with requires / in the end.
So we choose another option add blash all the time.
    acl is_root path -i /
    acl missing_slash path_reg [^\/]$
    acl function_suffix path_reg \.[a-zA-Z]{3,4}
acl host_community_sillycat    hdr_dom(host) -I community.sillycat.io
acl host_static_sillycat        hdr_dom(host) -I www.sillycat.io
acl host_sillycat                 hdr(host) -i sillycat.io
    http-request redirect code 301 prefix / append-slash if missing_slash !function_suffix !is_root host_community_sillycat
    http-request redirect code 301 prefix / append-slash if missing_slash !function_suffix !is_root host_static_sillycat
    http-request redirect code 301 prefix / append-slash if missing_slash !function_suffix !is_root host_sillycat

Command line to verify if it works
> curl -I https://www.sillycat.io/blog/free-google-ads-adwords-coupon-codes
HTTP/1.1 301 Moved Permanently
Content-length: 0
Location: /blog/free-google-ads-adwords-coupon-codes/

References:
http://www.voidcn.com/article/p-uezxokfw-em.html
https://github.com/ehazlett/interlock/blob/master/ext/lb/haproxy/template.go
https://stackoverflow.com/questions/47860773/haproxy-routing-based-on-url
https://github.com/vfarcic/docker-flow-proxy/issues/390
https://serverfault.com/questions/847599/haproxy-request-rewrite
https://discourse.haproxy.org/t/remove-the-trailing-slash/2278/16
分享到:
评论

相关推荐

    HAProxy配置文件详解和ACL功能.docx

    本文将深入讲解HAProxy配置文件的各个部分以及ACL(访问控制列表)的功能。 首先,配置文件是HAProxy的灵魂,主要包括全局配置(global)、默认设置(defaults)、监听(listen)、前端(frontend)和后端(backend...

    ubuntu haproxy安装与配置详解

    HAProxy的ACL(Access Control Lists)功能允许基于特定条件对请求进行过滤和路由。例如,你可以根据HTTP请求的URL、Host头或特定查询参数来决定流量流向哪个后端服务器。ACL规则可以与其他选项结合使用,如`use_...

    haproxy-1.8.23-1.el7.x86_64.rpm haproxy 1.8.23 rpm包

    haproxy-1.8.23 RPM包 for Centos7 rpm -ivh 安装即可,软件目录:/usr/local/haproxy-1.8.23 配置文件: /etc/haproxy/haproxy.cfg 可通过 systemctl 来进行 start 、stop 、restart 可通过 systemctl enable...

    haproxy-1.8.18.tar.gz

    haproxy支持多种高级特性,如会话持久化(session persistence)、统计页面、ACL(访问控制列表)以及健康检查等。会话持久化允许相同客户端的请求被连续转发到同一台后端服务器,保持服务状态的一致性。ACL则可以...

    haproxy-1.8.14 windows 最新稳定版本

    haproxy是一款高性能、高可用的网络负载均衡软件,它被广泛应用于服务器集群环境中,用于分发网络请求,提高服务的响应速度和并发处理能力。haproxy-1.8.14是针对Windows平台的一个最新稳定版本,包含了运行所需的...

    HAProxy用法详解.pdf

    3. frontend:接受请求的前端虚拟节点,可以根据ACL规则直接指定要使用的后端backend。 4. backend:提供服务的后端节点,可以是web服务器、数据库服务器等。 5. listen:_frontend和backend的组合体,用于定义服务...

    一个典型的Haproxy_exporter的监控metric例子.txt

    一个典型的Haproxy_exporter的监控metric例子 包含指标 haproxy_backend_bytes_in_total haproxy_backend_bytes_out_total haproxy_backend_client_aborts_total haproxy_backend_compressor_bytes_bypassed_total ...

    用haproxy实现RDP会话负载均衡

    用haproxy实现RDP会话负载均衡 HAProxy是一款免费、快速、可靠的解决方案,提供高可用性、负载均衡和基于TCP和HTTP应用的代理。它支持虚拟主机,运行在当前的硬件上,可以支持数以万计的并发连接。HAProxy特别适用...

    haproxy-3.1 for windows 64位 支持ssl

    在“haproxy-3.1 for windows 64位 支持ssl”这个版本中,特别强调了对Windows 64位操作系统的适配以及SSL(Secure Socket Layer)的支持。 SSL是一种网络安全协议,主要用于加密传输数据,确保在网络中传输的信息...

    haproxy安装与部署

    HAProxy安装与部署 HAProxy 是一种高性能的反向代理服务器软件,提供高可用性、负载均衡和基于 TCP 和 HTTP 应用的代理,支持虚拟主机。HAProxy 是一种免费、快速并且可靠的一种解决方案,特别适用于那些负载特大的...

    haproxy1.7 最新版本

    **haproxy1.7 最新版本** haproxy(High Availability Proxy)是一款开源的、高性能的负载均衡器和反向代理服务器,广泛应用于互联网服务的高可用性和负载分发。haproxy1.7是该软件的一个较新版本,发布于2016年,...

    haproxy资源学习

    ACL是HAProxy中用于条件匹配的重要工具,可以基于各种条件对请求进行过滤。如: ```bash acl bbs hdr_reg(host) -i ^(bbs.test.com|forum.test.com) ``` 此行代码定义了一个名为`bbs`的ACL规则,用于匹配请求头中的`...

    haproxy-2.8.0.tar.gz 二进制安装包,解压放置服务运行即可

    haproxy-2.8.0.tar.gz 是一个用于Linux环境的Haproxy二进制安装包,适用于CentOS 7.9操作系统。Haproxy是一款高性能、高可用的负载均衡器,它能够处理大量的网络连接,广泛应用于Web服务器集群的流量管理和故障切换...

    haproxy-3.1 for windows 64位 不支持ssl

    haproxy是一款广泛使用的开源负载均衡器,专为高可用性、高性能和安全性而设计。在本文中,我们将深入探讨haproxy-3.1 for Windows 64位版本的相关知识点,以及它不支持SSL的情况。 首先,haproxy-3.1是haproxy的一...

    haproxy-2.3.2-win64

    haproxy-2.3.2-win64是一款专为Windows 64位操作系统设计的高性能、免费的负载均衡器和反向代理软件。由Cygwin64编译环境构建,它允许在Windows平台上实现与Linux系统类似的Unix-like功能。Cygwin是一种GNU和开源...

    haproxy-1.7.10 windows 最新稳定版本

    haproxy是一款高性能、高可用的负载均衡器,它的全称是High Availability Proxy。这个软件在Linux和Windows等操作系统上广泛使用,为网络服务提供负载分发和故障切换功能,确保了服务的高可用性和可靠性。haproxy-...

    Haproxy使用手册.pdf

    HAProxy使用手册 HAProxy是开源的软负载均衡器,支持两种主要的代理模式:tcp(4层)和7层(HTTP)。在4层模式下,HAProxy仅在客户端和服务器之间转发双向流量。在7层模式下,HAProxy会分析协议,并且能通过允许、...

    haproxy镜像 2.9.9版本

    haproxy镜像 2.9.9版本

    haproxy负载均衡配置.docx

    haproxy是一款开源的高性能、高可用的网络负载均衡软件,它能够将进来的网络请求分发到多个后端服务器,以实现流量分摊、提高服务的可用性和响应速度。在配置haproxy时,主要涉及到以下几个核心概念和配置项: 1. *...

    haproxy windows

    haproxy是一款高性能的负载均衡器,主要用于在服务器集群中分发网络请求,确保服务的稳定性和高可用性。在Windows环境下,由于其主要设计和优化是针对Linux系统,因此通常需要借助像Cygwin这样的工具来编译和运行。...

Global site tag (gtag.js) - Google Analytics