我想代理传递的网址看起来像这样,请你帮我找出正确的正则表达式。我是个新手。
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
目前我的配置似乎不正常:
<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>
答案 0 :(得分:2)
您无法与ProxyPassMatch匹配查询字符串。你必须使用mod_rewrite来做到这一点。
# 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]