0

I got Apache 2.2.22 with mod_proxy and mod_proxy_ajp. Here is my configuration of mod_proxy:

    ProxyRequests Off      
    ProxyPreserveHost On   
    ProxyErrorOverride On
    ProxyPass / ajp://localhost:8009/
    ProxyPassReverse / http://www.myservice.com/

Generally it works fine but when you look at logs of mod_proxy you can see that few http headers are missing.

Header[0] [Host] = [www.myservice.com]
Header[1] [User-Agent] = [Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:23.0) Gecko/20100101 Firefox/23.0]
Header[2] [Accept] = [text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8]
Header[3] [Accept-Language] = [q=0.94,en-US;q=0.88,en;q=0.82,en-EN;q=0.76,fr-FR;q=0.71,fr;q=0.65,en-GB;q=0.18,ru;q=0.12,en-PL;q=0.06]
Header[4] [Accept-Encoding] = [gzip, deflate]
Header[5] [Cookie] = [_ga=GA1.2.190053753.1379368584; JSESSIONID=2f9c23613e546d91f2f59b6e4d81]

But the problem is that there is no header REMOTE_ADDR and my Glassfish3 server can't detect request's remote address and returns null.

I'm not sure but maybe the problem is not with mod_proxy but with glassfish.

m-szalik
  • 123
  • 3
  • please [read this q&a](http://stackoverflow.com/questions/760283/apache-proxypass-how-to-preserve-original-ip-address); if it doesnt help, make a comment below, thanx – that guy from over there Sep 19 '13 at 06:07

2 Answers2

0

i dont know how much googling your did, but "apache proxy real ip" gave me some interesting results.

please read this q&a; if it doesnt help, make a comment below, thanx

  • I've read it, but as you can see in my post there is no header "X-Forwarded-For" sent from apache to glassfish. Documentation says that it should be added autocratically, but it is not. – m-szalik Sep 19 '13 at 12:16
  • proxy_ajp should deliver this information (maybe not via HEADERS, [see here](http://tomcat.apache.org/connectors-doc/generic_howto/proxy.html)): client address: getRemoteAddr() – that guy from over there Sep 19 '13 at 15:33
0

I resolve this problem by setting extra header X-Forwarded-For to user's remote address.

        RewriteCond %{REMOTE_ADDR} (.*)
        RewriteRule .* -    [E=SEQ_ADDR:%1]
        RequestHeader set X-Forwarded-For %{SEQ_ADDR}e

And than using simple Filter in an application to read this header's value.

m-szalik
  • 123
  • 3