• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problems geting the request sender IP address

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I�m using apache as a proxy in port 80, so when it receives a request it forward the request to Jboss in the same machine. I have a servlet that gets the request sender IP address, but instead of geting the real IP adrress it gets the local valid address 200.212.90.xxx (my apache/Jboss server). In my action I use the method request.getRemoteAddr(). I also try to use request.getHeader(headerName) and I found some thing very intresting:

java.util.Enumeration enum = request.getHeaderNames();
while(enum.hasMoreElements()) {
String headerName = (String) enum.nextElement();
String headerValue = request.getHeader(headerName);
System.out.println("-----------------" + headerName + " : " + headerValue);
}

After runing this code I get the output:

-----------------accept : image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
-----------------referer : "Url"
-----------------accept-language : pt-br
-----------------content-type : application/x-www-form-urlencoded
-----------------accept-encoding : gzip, deflate
-----------------user-agent : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
-----------------host : "host name"
-----------------content-length : 99
-----------------connection : Keep-Alive
-----------------cache-control : no-cache
-----------------cookie : JSESSIONID=CD2572BA90ED1C220A2DE648C6B5E293

As you can see the request does not have the REMOTE_HOST or HTTP_X_FORWARDED_FOR, it only lists those fell headers. But if I use request.getRemoteAddr() it returns the local valid IP address and not the real request sender IP address. Why my lopp did�t list all the http headers, including REMOTE_HOST??? So the question is:

Is there a configuration at Apache so when it act as a proxy my action can get the real request sender IP address?
Or
Can I use another method or way to get the user IP address?

Somebody please help!!!
[ April 26, 2006: Message edited by: Frederico Zapelini ]
 
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you set up Apache as Proxy server? If you set it up as a web server and you access this server from some other machine in the network, surely u will get remote IP
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic