Apache HTTP Server Version 2.4
Available Languages: fr
Description: | Replaces the original client IP address for the connection with the agent IP address list presented by a proxies or a load balancer via the request headers. |
---|---|
Status: | Base |
Module Identifier: | remoteip_module |
Source File: | mod_remoteip.c |
This module is used to treat the agent which initiated the request as the originating agent as identified by httpd for the purposes of authorization and logging, even where that agent is behind a load balancer, front end server, or proxy server.
The module overrides the client IP address for the connection with the agent IP address reported in the request header configured with the RemoteIPHeader
directive.
Additionally, this module implements the server side of HAProxy's PROXY Protocol when using the RemoteIPProxyProtocol
directive.
Once replaced as instructed, this overridden agent IP address is then used for the core
%a
format strings. The underlying client IP of the connection is available in the %{c}a
format string.
Apache by default identifies the agent with the connection's client_ip value, and the connection remote_host and remote_logname are derived from this value. These fields play a role in authentication, authorization and logging and other purposes by other loadable modules.
mod_remoteip overrides the client IP of the connection with the d agent IP as provided by a proxy or load balancer, for the duration of the request. A load balancer might establish a long lived keepalive connection with the server, and each request will have the correct agent IP, even though the underlying client IP address of the load balancer remains unchanged.
When multiple, comma delimited agent IP addresses are listed in the header value, they are processed in Right-to-Left order. Processing halts when a given agent IP address is not trusted to present the preceding IP address. The header field is updated to this remaining list of unconfirmed IP addresses, or if all IP addresses were trusted, this header is removed from the request altogether.
In overriding the client IP, the module stores the list of intermediate hosts in a remoteip-proxy-ip-list note, which RemoteIPProxiesHeader
.
RemoteIPInternalProxy
internal (intranet) proxies are ed.
Description: | Declare the header field which should be parsed for agent IP addresses |
---|---|
Syntax: | RemoteIPHeader header-field |
Context: | server config, virtual host |
Status: | Base |
Module: | mod_remoteip |
The RemoteIPHeader
IP value.
RemoteIPHeader X-Client-IP
RemoteIPHeader X-Forwarded-For
Description: | Declare client intranet IP addresses trusted to present the RemoteIPHeader value |
---|---|
Syntax: | RemoteIPInternalProxy proxy-ip|proxy-ip/subnet|hostname ... |
Context: | server config, virtual host |
Status: | Base |
Module: | mod_remoteip |
The RemoteIPTrustedProxy
directive, any IP address presented in this header, including private intranet addresses, are trusted when ed from these proxies.
RemoteIPHeader X-Client-IP RemoteIPInternalProxy 10.0.2.0/24 RemoteIPInternalProxy gateway.localdomain
Description: | Declare client intranet IP addresses trusted to present the RemoteIPHeader value |
---|---|
Syntax: | RemoteIPInternalProxyList filename |
Context: | server config, virtual host |
Status: | Base |
Module: | mod_remoteip |
The RemoteIPInternalProxyList
directive specifies a file parsed at startup, and builds a list of addresses (or address blocks) to trust as presenting a valid RemoteIPHeader value of the agent IP.
The '#
' hash character designates a comment line, otherwise each whitespace or newline separated entry is processed identically to the RemoteIPInternalProxy
directive.
RemoteIPHeader X-Client-IP RemoteIPInternalProxyList conf/trusted-proxies.lst
# Our internally trusted proxies; 10.0.2.0/24 #Everyone in the testing group gateway.localdomain #The front end balancer
Description: | Declare the header field which will record all intermediate IP addresses |
---|---|
Syntax: | RemoteIPProxiesHeader HeaderFieldName |
Context: | server config, virtual host |
Status: | Base |
Module: | mod_remoteip |
The RemoteIPInternalProxy
addresses are discarded.
RemoteIPHeader X-Forwarded-For RemoteIPProxiesHeader X-Forwarded-By
Description: | Enable or disable PROXY protocol handling |
---|---|
Syntax: | RemoteIPProxyProtocol On|Off |
Context: | server config, virtual host |
Status: | Base |
Module: | mod_remoteip |
Compatibility: | RemoteIPProxyProtocol is only available in httpd 2.4.31 and newer |
The RemoteIPProxyProtocol
directive enables or disables the reading and handling of the PROXY protocol connection header. If enabled with the On
flag, the upstream client must send the header every time it opens a connection or the connection will be aborted unless it is in the list of disabled hosts provided by the RemoteIPProxyProtocolExceptions
directive.
While this directive may be specified in any virtual host, it is important to understand that because the PROXY protocol is connection based and protocol agnostic, the enabling and disabling is actually based on IP address and port. This means that if you have multiple name-based virtual hosts for the same host and port, and you enable it for any one of them, then it is enabled for all of them (with that host and port). It also means that if you attempt to enable the PROXY protocol in one and disable in the other, that won't work; in such a case, the last one wins and a notice will be logged indicating which setting was being overridden.
Listen 80 <VirtualHost *:80> ServerName www.example.com RemoteIPProxyProtocol On #Requests to this virtual host must have a PROXY protocol # header provided. If it is missing, the connection will # be aborted </VirtualHost> Listen 8080 <VirtualHost *:8080> ServerName www.example.com RemoteIPProxyProtocol On RemoteIPProxyProtocolExceptions 127.0.0.1 10.0.0.0/8 #Requests to this virtual host must have a PROXY protocol # header provided. If it is missing, the connection will # be aborted except when coming from localhost or the # 10.x.x.x RFC1918 range </VirtualHost>
Description: | Disable processing of PROXY header for certain hosts or networks |
---|---|
Syntax: | RemoteIPProxyProtocolExceptions host|range [host|range] [host|range] |
Context: | server config, virtual host |
Status: | Base |
Module: | mod_remoteip |
Compatibility: | RemoteIPProxyProtocolExceptions is only available in httpd 2.4.31 and newer |
The RemoteIPProxyProtocol
directive enables or disables the reading and handling of the PROXY protocol connection header. Sometimes it is desirable to require clients to provide the PROXY header, but permit other clients to connect without it. This directive allows a server to configure a single host or CIDR range of hosts that may do so. This is generally useful for monitoring and istrative traffic to a virtual host direct to the server behind the upstream load balancer.
Description: | Declare client intranet IP addresses trusted to present the RemoteIPHeader value |
---|---|
Syntax: | RemoteIPTrustedProxy proxy-ip|proxy-ip/subnet|hostname ... |
Context: | server config, virtual host |
Status: | Base |
Module: | mod_remoteip |
The RemoteIPHeader
header's value.
RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxy 10.0.2.16/28 RemoteIPTrustedProxy proxy.example.com
Description: | Declare client intranet IP addresses trusted to present the RemoteIPHeader value |
---|---|
Syntax: | RemoteIPTrustedProxyList filename |
Context: | server config, virtual host |
Status: | Base |
Module: | mod_remoteip |
The RemoteIPTrustedProxyList
directive specifies a file parsed at startup, and builds a list of addresses (or address blocks) to trust as presenting a valid RemoteIPHeader value of the agent IP.
The '#
' hash character designates a comment line, otherwise each whitespace or newline separated entry is processed identically to the RemoteIPTrustedProxy
directive.
RemoteIPHeader X-Forwarded-For RemoteIPTrustedProxyList conf/trusted-proxies.lst
# Identified external proxies;
192.0.2.16/28 #wap phone group of proxies
proxy.isp.example.com #some well known ISP
Available Languages: fr