问题
I have a REST service that accepts parameters in a form /{parameter}
Also there is Apache2 that forwards requests to the websevice
<VirtualHost *:9091>
AllowEncodedSlashes NoDecode
LogLevel debug
ProxyPass /webservice balancer://api/webservice
<Proxy balancer://api>
BalancerMember http://localhost:8030
</Proxy>
</VirtualHost>
Parameters may contain encoded characters, like %2f (/)
The problem is that Apache encodes these characters again, and Webservice receives %252F instead of %2F
[Mon Oct 15 13:59:24 2012] [debug] mod_proxy_balancer.c(46): proxy: BALANCER: canonicalising URL //api/webservice/Interface GigabitEthernet1%2F0%2F2
[Mon Oct 15 13:59:24 2012] [debug] mod_proxy_balancer.c(581): proxy: BALANCER (balancer://api) worker (http://localhost:8030) rewritten to http://localhost:8030/Interface%20GigabitEthernet1%252F0%252F2%20Utilization
If I request the webservice directtly, Tomcat/Jetty handles it find and service receives correct parameter.
回答1:
Solved by specifying
ProxyPass /webservice balancer://api/webservice nocanon
回答2:
A little bit off topic since this does not solve the problem with slashes but I will add it here anyway if anyone else runs in to the same problem as I had.
I had a similar problem that swedish special characters (åäö) in url parameters were not handled correctly when passed through apache proxy. It turned out that apache was doing fine but in the receiving tomcat instance the AJP-connector was missing URIEncoding configuration.
From my tomcat server.xml:
<Connector port="8009" protocol="AJP/1.3" redirectPort="8080" URIEncoding="UTF-8"/>
来源:https://stackoverflow.com/questions/12895674/apache-mod-proxy-url-encoding