Apache mod_proxy url encoding

若如初见. 提交于 2020-01-22 09:41:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!