In my apache configuration I am matching on some url and trying to redirect that to another location. For the most part this configuration is working. The part that is not is the query parameter on the proxy pass url. All my research is leading me to a RewriteRule, but that makes no sense to me since I am completely throwing away the incoming url as it doesn't matter after it's used to match the Location block.
<Location "/src">
ProxyErrorOverride Off
ProxyPass https://example.com/dst/v1234?user=me
ProxyPassReverse https://example.com/dst/v1234?user=me
Header set Cache-Control "max-age=604800, public"
</Location
When I am testing I can see the following:
Web Server: POST http://localhost/src -d { "data": true }
App Server: POST https://example.com/dst/v1234?user=me -d { "data": true }
The App Server doesn't know how to interpret the ?
even though that's url encoding for the question mark (?). The App Server is not under my control and I can't change that code to decode this for me. How can I get Apache to send the question mark (?) instead of the url encoded variant?
CodePudding user response:
After much research and another very helpful Stack Overflow post. I found a solution!
ProxyPass /webservice balancer://api/webservice nocanon
The answer is to use nocanon
.
<Location "/src">
ProxyErrorOverride Off
ProxyPass https://example.com/dst/v1234?user=me nocanon
ProxyPassReverse https://example.com/dst/v1234?user=me
Header set Cache-Control "max-age=604800, public"
</Location
Normally, mod_proxy will canonicalise ProxyPassed URLs. But this may be incompatible with some backends, particularly those that make use of PATH_INFO. The optional nocanon keyword suppresses this and passes the URL path "raw" to the backend. Note that this keyword may affect the security of your backend, as it removes the normal limited protection against URL-based attacks provided by the proxy.