ProxyPassMatch 与正则表达式
ProxyPassMatch with regex
我想要代理通行证的 url 看起来像这样,你能帮我找出正确的正则表达式吗?我是 apache 新手。
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=
RequestHeader set X-Forwarded-Proto "https"
</VirtualHost>
您无法使用 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]
我想要代理通行证的 url 看起来像这样,你能帮我找出正确的正则表达式吗?我是 apache 新手。
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=
RequestHeader set X-Forwarded-Proto "https"
</VirtualHost>
您无法使用 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]