Custom Resolution of Client's Originating IP Address
Introduction
Goal
Configure the HTTP header(s) to read the client's originating IP address from.
Background
Sometimes both the delivery tier and authoring tier need to recognize the client's originating IP address for various reasons. For example, you might want to enable HST Page Diagnostics or CMS Diagnostics only when accessed by some clients with specific IP addresses. Or you might want to use the GeoIPCollector in Relevance Module so that the visitors may get personalized pages based on where they come from.
By default, Bloomreach Experience Manager reads X-Forwarded-For HTTP header or falls back to javax.servlet.ServletRequest#getRemoteAddr() if the hearder isn't available. This is a resonable default configuration for most environments.
However, sometimes you need to use a different HTTP headers when the loadbalancer or HTTP servers in your environment provide a different HTTP header other than X-Forwarded-For.
Bloomreach Experience Manager provides a flexibly way to configure which HTTP header(s) to use in clients' originating IP addresses, in $CATALINA_BASE/conf/context.xml file.
Configuration for HTTP 'Forwarded For' Header
Suppose you can get the client's originating IP address from X-FOO-Forwarded-For HTTP header instead, as an example, in your environment. Then you should add the http-forwarded-for-header parameter in $CATALINA_BASE/conf/context.xml like the following example:
<?xml version='1.0' encoding='utf-8'?> <Context> <!-- SNIP --> <Parameter name="http-forwarded-for-header" value="X-FOO-Forwarded-For" override="false" /> <!-- SNIP --> </Context>
That's it. With the configuration, both delivery tier and authoring tier and GeoIPCollector in Relevance Module will start recognizing the clients' originating IP addresses by looking up the specificed HTTP header.