path - haproxy 将 URL 路径重定向到另一个路径
问题描述
haproxy 版本 1.5.18
我想重定向:
/document/(.*)/(.*)/somefile => /anotherPath/somefile
例如:重定向
/document/20181/20182/a_good_pic.jpg => /anotherPath/a_good_pic.jpg
如何用 haproxy 做到这一点?
我重试了 reqirep 的示例,例如:
# replace "/static/" with "/" at the beginning of any request path.
reqrep ^([^\ :]*)\ /static/(.*) \1\ /\2
但是我的示例在 URL 路径中有两个部分与示例不同,所以我很困惑。
谢谢!
解决方案
您可以声明一个 acl,然后执行一个有条件的 use_backend 语句。像这样:
frontend a-frontend-conf
# Declare an ACL using path_beg (Path Begins)
acl path_images path_beg /images
# Use backend server1 if acl condition path_images is fulfilled
use_backend server1 if path_images
backend server1
[...]
来源:https ://serverfault.com/questions/659793/haproxy-how-to-balance-traffic-within-directory-reached
推荐阅读
- c# - Windows XP .NET Framework 4.0 中 WPF xaml 中的异常
- r - rmarkdown 期刊文章模板
- android - 如何将回收器高度设置为 recyclerView 中的最高项目?
- javascript - 剑道的层次图
- mysql - 尝试更新现有记录 - 出现错误
- c# - 如何在服务器端设置没有 id 属性的 Input 元素的值?
- apache-spark - 如何在不使用 sparkListener 操作的情况下为不同的数据帧写入记录计数?
- node.js - 无法在启用了 Istio 的 GKE 集群中的 2 个节点、js 应用程序之间进行通信
- java - Android - 将 MediaMuxer 与 MediaExtractor 和 PCM 流一起使用会导致视频帧损坏
- python-3.x - ImportError:无法导入名称“extract_zipped_paths”