isotronic
isotronic

Reputation: 67

Is remote address the same as x-forwarded-for?

I need to get the x-forwarded-for header from requests. Since i already have an http filter, i can easily log remote address using HttpServletRequest.getRemoteAddr(), whereas logging x-forwarded-for would require additional configuration. My question is, will the HttpServletRequest.getRemoteAddr() return the same address as x-forwarded-for, are x-forwarded-for and remote address the same?

Upvotes: 2

Views: 4517

Answers (1)

Abdulah Pehlic
Abdulah Pehlic

Reputation: 189

No, HttpServletRequest.getRemoteAddr() will return the address of the last proxy, or load balancer through which the request was sent. X-Forwarded-For will return the original address, from which the request was first sent, followed with the address of the proxy or the load balancer.

Upvotes: 4

Related Questions