问题描述
我要代理传递的网址看起来像这样,请您帮我弄清楚正确的正则表达式.我是一个Apache新手.
The url i'd like to proxy pass looks something like this, could you please help me figure out the correct regex. I'm a apache newbie.
https://example.com/v1/documents?uri=root/support/bugtracking/attachments/29099/support-log.txt
我希望将 root/support/bugtracking/attachments/29099/support-log.txt
传递给 https://other-server/download.xqy?file =root/support/bugtracking/attachments/29099/support-log.txt
当前,我具有以下似乎无法正常工作的配置:
Currently i have the below configuration which does not seem to be working:
<VirtualHost *:443>
ServerName example.com
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:!LOW
SSLCertificateFile /etc/httpd/certs/cert.pem
SSLCertificateKeyFile /etc/httpd/certs/key.pem
SSLCACertificateFile /etc/httpd/certs/ca.cert.pem
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:9050/
ProxyPassReverse / http://localhost:9050/
ProxyPassMatch ^/v1/documents?uri=(root/support/bugtracking/*)$ https://other-server.com/download.xqy?file=$1
RequestHeader set X-Forwarded-Proto "https"
</VirtualHost>
推荐答案
您无法使用ProxyPassMatch与查询字符串进行匹配.您必须使用mod_rewrite来做到这一点.
You cannot match against the query string with ProxyPassMatch. You'll have to use mod_rewrite to do it.
# XXX: This creates a "worker" for this backend when
# not using ProxyPass.
<Proxy https://other-server.com/>
# Actual thing being set is redundant
ProxySet keepalive=On
</Proxy>
RewriteEngine ON
RewriteCond %{QUERY_STRING} uri=(root/support/bugtracking/.*)$
RewriteRule ^/v1/documents https://other-server.com/download.xqy?file=%1 [P]
这篇关于带有正则表达式的ProxyPassMatch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!