Apache mod_proxy ProxyPassMatch 正则表达式

发布于 2025-01-03 12:32:04 字数 469 浏览 5 评论 0原文

我使用 mod_proxy 将 Apache 设置为非公共后端服务器的反向代理。然而,我的 ProxyPassMatch 指令之一总是返回 404:

ProxyPassMatch ^/app/files/public/orders/06_production/jobs/([a-zA-Z0-9\-]+)/Preview%20PNG/(V[0-9]+)/([a-zA-Z0-9_\-]+.png)$ http://192.168.2.42/app/files/public/orders/06_production/jobs/$1/Preview%20PNG/$2/$3

这应该与这样的传入请求匹配:

/app/files/public/orders/06_production/jobs/P116087/Preview%20PNG/V1/bla.png

知道我的正则表达式出了什么问题吗?

I've setup Apache as a reverse proxy for a non public backend server, using mod_proxy. However one of my ProxyPassMatch directives always returns 404:

ProxyPassMatch ^/app/files/public/orders/06_production/jobs/([a-zA-Z0-9\-]+)/Preview%20PNG/(V[0-9]+)/([a-zA-Z0-9_\-]+.png)$ http://192.168.2.42/app/files/public/orders/06_production/jobs/$1/Preview%20PNG/$2/$3

This should match an incoming request like this:

/app/files/public/orders/06_production/jobs/P116087/Preview%20PNG/V1/bla.png

Any idea what's wrong with my Regex?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不气馁 2025-01-10 12:32:04

想通了:

ProxyPassMatch "\A/app/files/public/orders/06_production/jobs/([a-zA-Z0-9\-]+)/Preview PNG/(V[0-9]+)/([a-zA-Z0-9_\-]+.png)\z" "http://192.168.2.42/app/files/public/orders/06_production/jobs/$1/Preview PNG/$2/$3"

Figured it out:

ProxyPassMatch "\A/app/files/public/orders/06_production/jobs/([a-zA-Z0-9\-]+)/Preview PNG/(V[0-9]+)/([a-zA-Z0-9_\-]+.png)\z" "http://192.168.2.42/app/files/public/orders/06_production/jobs/$1/Preview PNG/$2/$3"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文