Apache mod_proxy url encoding
Asked Answered
Y

2

14

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.

Yulma answered 15/10, 2012 at 12:26 Comment(0)
Y
17

Solved by specifying

ProxyPass /webservice balancer://api/webservice nocanon
Yulma answered 15/1, 2013 at 13:41 Comment(0)
A
1

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"/>
Adumbrate answered 10/9, 2015 at 7:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.