Configuration HAProxy-重写URL';透明的

Configuration HAProxy-重写URL';透明的,configuration,url-rewriting,acl,haproxy,Configuration,Url Rewriting,Acl,Haproxy,我需要为一个项目实现一个URL重写操作。这必须通过HAProxy-1.5实现,因为它是在PfSense防火墙上实现的,目前还没有更高版本 我有以下网址: update.domain.com repository.domain.com 两者都指向同一后端服务器1。现在的挑战是移动文档根目录: -update.domain.com>>/some/path/repo1。 -repository.domian.com>/some/path/repo2 不仅文档根被移动,而且由于TMG服务器的早期实现,存

我需要为一个项目实现一个URL重写操作。这必须通过HAProxy-1.5实现,因为它是在PfSense防火墙上实现的,目前还没有更高版本

我有以下网址: update.domain.com repository.domain.com 两者都指向同一后端服务器1。现在的挑战是移动文档根目录: -update.domain.com>>/some/path/repo1。 -repository.domian.com>/some/path/repo2

不仅文档根被移动,而且由于TMG服务器的早期实现,存在指向以下文件的链接: update.domain.com/file1.txt

我曾尝试在前端使用http请求集路径和一些ACL,但不幸的是,此功能在版本>haproxy-1.6中可用

frontend www
 bind *:80 
 acl    update_url  hdr_beg(host) -m beg update.domain.com 
 acl    update_root path_beg /some/path/repo1/
 http-request set-header /some/path/repo1/%[path] if !update_root update_url    
 use_backend testServer if update_root update_url
 default_backend testServer 

无法更改指向update.domain.com/file1.txt等文件的链接。保留TMG不是一个解决方案。如何使用Haproxy-1.5实现这一点?

对于Haproxy 1.5,您可以使用,它将用您在正则表达式中指定的内容替换请求行(以及任何标题行),例如:

reqrep ^([^\ :]*)\ /some/path/repo1/(.*) \1\ /some/path/repo2\2
有关如何使用
reqrep
的详细说明,请参见