You need to sign in to do that
Don't have an account?
HTTP Header Values for client IP Address
I am looking for the most reliable way to know the IP address of the client machine visiting my Sites page. Looking at all the available headers on the page using ApexPages.currentPage().getHeaders(), I see several options like "True-Client-IP", "X-Forwarded-For" and "X-Salesforce-SIP"
"True-Client-IP" seems to be accurate all the time, but isn't always present.
"X-Forwarded-For" has a couple IP addresses in thereso I need to parse the list of IPs. According to Wikipedia, this is somewhat of a standard header. However, I always thought anything with "X-" is custom and not standard.
"X-Salesforce-SIP" is another that seems to be accurate on some pages, but on others it's not.
What's the most reliable? In what situations are these header values populated? Are there other values I should look for?
My code may look for all possible headers, but I want to start with the most reliable and try to understand the situations in which that are populated.
True-Client-IP has the value when the request is coming via the caching integration.
X-Salesforce-SIP has the value if there is no caching integration (sandbox, developer edition orgs) or via the secure url
All Answers
True-Client-IP has the value when the request is coming via the caching integration.
X-Salesforce-SIP has the value if there is no caching integration (sandbox, developer edition orgs) or via the secure url