Technical Tip: How to Detect Originating IP Address within XFF Header Using Proxy Address
| Description | This article describes how to use the Proxy Address to detect an IP address hidden within the X-Forwarded-For header of an HTTP request. Proxy Address provides several address types, and the article will cover the HTTP Header address type. |
| Scope | FortiProxy. |
| Solution | Create a proxy address object with a desired IP address within the X-Forwarded-For header, that is referred to an explicit web proxy policy.
config firewall proxy-address edit "xff-addr1" set type header next end
config firewall policy edit 3 set type explicit-web next end
When a client initiates a connection to 'www.google.com' by sending an HTTP request containing the X-Forwarded-For header, FortiProxy processes the session based on the action specified in the explicit web proxy policy.
Forward Traffic event:
In the case of multiple addresses in the X-Forwarded-For header, the header regex pattern can be constructed as follows:
"\b10\.0\.1\.250\b"
"\b(?:10\.0\.1\.250|192\.168\.0\.250)\b"
"^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:, (?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))*$" |

