]> granicus.if.org Git - apache/blob - docs/manual/mod/mod_remoteip.html.en
59bd4f3d7ba7f6f7491a2db11245ce05015115b0
[apache] / docs / manual / mod / mod_remoteip.html.en
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
4 <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
5 <!--
6         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7               This file is generated from xml source: DO NOT EDIT
8         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
9       -->
10 <title>mod_remoteip - Apache HTTP Server Version 2.5</title>
11 <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
12 <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
13 <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
14 <script src="../style/scripts/prettify.min.js" type="text/javascript">
15 </script>
16
17 <link href="../images/favicon.ico" rel="shortcut icon" /></head>
18 <body>
19 <div id="page-header">
20 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
21 <p class="apache">Apache HTTP Server Version 2.5</p>
22 <img alt="" src="../images/feather.png" /></div>
23 <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
24 <div id="path">
25 <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.5</a> &gt; <a href="./">Modules</a></div>
26 <div id="page-content">
27 <div id="preamble"><h1>Apache Module mod_remoteip</h1>
28 <div class="toplang">
29 <p><span>Available Languages: </span><a href="../en/mod/mod_remoteip.html" title="English">&nbsp;en&nbsp;</a> |
30 <a href="../fr/mod/mod_remoteip.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
31 </div>
32 <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Replaces the original client IP address for the connection
33 with the useragent IP address list presented by a proxies or a load balancer
34 via the request headers.
35 </td></tr>
36 <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
37 <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>remoteip_module</td></tr>
38 <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_remoteip.c</td></tr></table>
39 <h3>Summary</h3>
40
41     <p>This module is used to treat the useragent which initiated the
42     request as the originating useragent as identified by httpd for the
43     purposes of authorization and logging, even where that useragent is
44     behind a load balancer, front end server, or proxy server.</p>
45
46     <p>The module overrides the client IP address for the connection
47     with the useragent IP address reported in the request header configured
48     with the <code class="directive"><a href="#remoteipheader">RemoteIPHeader</a></code> directive.</p>
49
50     <p>Once replaced as instructed, this overridden useragent IP address is
51     then used for the <code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code>
52     <code class="directive"><a href="../mod/mod_authz_core.html#require">Require ip</a></code>
53     feature, is reported by <code class="module"><a href="../mod/mod_status.html">mod_status</a></code>, and is recorded by
54     <code class="module"><a href="../mod/mod_log_config.html">mod_log_config</a></code> <code>%a</code> and <code class="module"><a href="../mod/core.html">core</a></code>
55     <code>%a</code> format strings. The underlying client IP of the connection
56     is available in the <code>%{c}a</code> format string.</p>
57
58     <div class="warning">It is critical to only enable this behavior from
59     intermediate hosts (proxies, etc) which are trusted by this server, since
60     it is trivial for the remote useragent to impersonate another
61     useragent.</div>
62 </div>
63 <div id="quickview"><h3>Topics</h3>
64 <ul id="topics">
65 <li><img alt="" src="../images/down.gif" /> <a href="#processing">Remote IP Processing</a></li>
66 </ul><h3 class="directives">Directives</h3>
67 <ul id="toc">
68 <li><img alt="" src="../images/down.gif" /> <a href="#remoteipheader">RemoteIPHeader</a></li>
69 <li><img alt="" src="../images/down.gif" /> <a href="#remoteipinternalproxy">RemoteIPInternalProxy</a></li>
70 <li><img alt="" src="../images/down.gif" /> <a href="#remoteipinternalproxylist">RemoteIPInternalProxyList</a></li>
71 <li><img alt="" src="../images/down.gif" /> <a href="#remoteipproxiesheader">RemoteIPProxiesHeader</a></li>
72 <li><img alt="" src="../images/down.gif" /> <a href="#remoteiptrustedproxy">RemoteIPTrustedProxy</a></li>
73 <li><img alt="" src="../images/down.gif" /> <a href="#remoteiptrustedproxylist">RemoteIPTrustedProxyList</a></li>
74 </ul>
75 <h3>Bugfix checklist:</h3><ul class="seealso"><li><a href="https://www.apache.org/dist/httpd/CHANGES_2.4">HTTPD changelog</a></li><li><a href="https://bz.apache.org/bugzilla/buglist.cgi?bug_status=__open__&amp;list_id=144532&amp;product=Apache%20httpd-2&amp;query_format=specific&amp;order=changeddate%20DESC%2Cpriority%2Cbug_severity&amp;component=mod_remoteip">Known issues</a></li><li><a href="https://bz.apache.org/bugzilla/enter_bug.cgi?product=Apache%20httpd-2">Report a bug</a></li></ul><h3>See also</h3>
76 <ul class="seealso">
77 <li><code class="module"><a href="../mod/mod_authz_host.html">mod_authz_host</a></code></li>
78 <li><code class="module"><a href="../mod/mod_status.html">mod_status</a></code></li>
79 <li><code class="module"><a href="../mod/mod_log_config.html">mod_log_config</a></code></li>
80 </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
81 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
82 <div class="section">
83 <h2><a name="processing" id="processing">Remote IP Processing</a></h2>
84
85     <p>Apache by default identifies the useragent with the connection's
86     client_ip value, and the connection remote_host and remote_logname are
87     derived from this value. These fields play a role in authentication,
88     authorization and logging and other purposes by other loadable
89     modules.</p>
90
91     <p>mod_remoteip overrides the client IP of the connection with the
92     advertised useragent IP as provided by a proxy or load balancer, for
93     the duration of the request. A load balancer might establish a long
94     lived keepalive connection with the server, and each request will
95     have the correct useragent IP, even though the underlying client IP
96     address of the load balancer remains unchanged.</p>
97
98     <p>When multiple, comma delimited useragent IP addresses are listed in the
99     header value, they are processed in Right-to-Left order.  Processing
100     halts when a given useragent IP address is not trusted to present the
101     preceding IP address.  The header field is updated to this remaining
102     list of unconfirmed IP addresses, or if all IP addresses were trusted,
103     this header is removed from the request altogether.</p>
104
105     <p>In overriding the client IP, the module stores the list of intermediate
106     hosts in a remoteip-proxy-ip-list note, which <code class="module"><a href="../mod/mod_log_config.html">mod_log_config</a></code>
107     can record using the <code>%{remoteip-proxy-ip-list}n</code> format token.
108     If the administrator needs to store this as an additional header, this
109     same value can also be recording as a header using the directive
110     <code class="directive"><a href="#remoteipproxiesheader">RemoteIPProxiesHeader</a></code>.</p>
111
112     <div class="note"><h3>IPv4-over-IPv6 Mapped Addresses</h3>
113     As with httpd in general, any IPv4-over-IPv6 mapped addresses are recorded
114     in their IPv4 representation.</div>
115
116     <div class="note"><h3>Internal (Private) Addresses</h3>
117     All internal addresses 10/8, 172.16/12, 192.168/16, 169.254/16 and 127/8
118     blocks (and IPv6 addresses outside of the public 2000::/3 block) are only
119     evaluated by mod_remoteip when <code class="directive"><a href="#remoteipinternalproxy">RemoteIPInternalProxy</a></code>
120     internal (intranet) proxies are registered.</div>
121
122 </div>
123 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
124 <div class="directive-section"><h2><a name="RemoteIPHeader" id="RemoteIPHeader">RemoteIPHeader</a> <a name="remoteipheader" id="remoteipheader">Directive</a></h2>
125 <table class="directive">
126 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Declare the header field which should be parsed for useragent IP addresses</td></tr>
127 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RemoteIPHeader <var>header-field</var></code></td></tr>
128 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
129 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
130 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_remoteip</td></tr>
131 </table>
132     <p>The <code class="directive"><a href="#remoteipheader">RemoteIPHeader</a></code> directive triggers
133     <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> to treat the value of the specified
134     <var>header-field</var> header as the useragent IP address, or list
135     of intermediate useragent IP addresses, subject to further configuration
136     of the <code class="directive"><a href="#remoteipinternalproxy">RemoteIPInternalProxy</a></code> and
137     <code class="directive"><a href="#remoteiptrustedproxy">RemoteIPTrustedProxy</a></code> directives.</p>
138
139     <div class="warning"> Unless these other directives are used, <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> 
140     will trust all hosts presenting a non internal address in the 
141     <code class="directive"><a href="#remoteipheader">RemoteIPHeader</a></code> header value.
142     </div>
143
144     <div class="example"><h3>Internal (Load Balancer) Example</h3><pre class="prettyprint lang-config">RemoteIPHeader X-Client-IP</pre>
145 </div>
146
147     <div class="example"><h3>Proxy Example</h3><pre class="prettyprint lang-config">RemoteIPHeader X-Forwarded-For</pre>
148 </div>
149
150 </div>
151 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
152 <div class="directive-section"><h2><a name="RemoteIPInternalProxy" id="RemoteIPInternalProxy">RemoteIPInternalProxy</a> <a name="remoteipinternalproxy" id="remoteipinternalproxy">Directive</a></h2>
153 <table class="directive">
154 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Declare client intranet IP addresses trusted to present the RemoteIPHeader value</td></tr>
155 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RemoteIPInternalProxy <var>proxy-ip</var>|<var>proxy-ip/subnet</var>|<var>hostname</var> ...</code></td></tr>
156 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
157 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
158 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_remoteip</td></tr>
159 </table>
160     <p>The <code class="directive"><a href="#remoteipinternalproxy">RemoteIPInternalProxy</a></code> directive adds one
161     or more addresses (or address blocks) to trust as presenting a valid
162     RemoteIPHeader value of the useragent IP.  Unlike the
163     <code class="directive"><a href="#remoteiptrustedproxy">RemoteIPTrustedProxy</a></code> directive, any IP address
164     presented in this header, including private intranet addresses, are
165     trusted when passed from these proxies.</p>
166
167     <div class="example"><h3>Internal (Load Balancer) Example</h3><pre class="prettyprint lang-config">RemoteIPHeader X-Client-IP
168 RemoteIPInternalProxy 10.0.2.0/24
169 RemoteIPInternalProxy gateway.localdomain</pre>
170 </div>
171
172 </div>
173 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
174 <div class="directive-section"><h2><a name="RemoteIPInternalProxyList" id="RemoteIPInternalProxyList">RemoteIPInternalProxyList</a> <a name="remoteipinternalproxylist" id="remoteipinternalproxylist">Directive</a></h2>
175 <table class="directive">
176 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Declare client intranet IP addresses trusted to present the RemoteIPHeader value</td></tr>
177 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RemoteIPInternalProxyList <var>filename</var></code></td></tr>
178 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
179 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
180 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_remoteip</td></tr>
181 </table>
182     <p>The <code class="directive"><a href="#remoteipinternalproxylist">RemoteIPInternalProxyList</a></code> directive specifies
183     a file parsed at startup, and builds a list of addresses (or address blocks)
184     to trust as presenting a valid RemoteIPHeader value of the useragent IP.</p>
185
186     <p>The '<code>#</code>' hash character designates a comment line, otherwise
187     each whitespace or newline separated entry is processed identically to
188     the <code class="directive"><a href="#remoteipinternalproxy">RemoteIPInternalProxy</a></code> directive.</p>
189
190     <div class="example"><h3>Internal (Load Balancer) Example</h3><pre class="prettyprint lang-config">RemoteIPHeader X-Client-IP
191 RemoteIPInternalProxyList conf/trusted-proxies.lst</pre>
192 </div>
193
194     <div class="example"><h3>conf/trusted-proxies.lst contents</h3><pre># Our internally trusted proxies;
195 10.0.2.0/24         #Everyone in the testing group
196 gateway.localdomain #The front end balancer</pre></div>
197
198 </div>
199 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
200 <div class="directive-section"><h2><a name="RemoteIPProxiesHeader" id="RemoteIPProxiesHeader">RemoteIPProxiesHeader</a> <a name="remoteipproxiesheader" id="remoteipproxiesheader">Directive</a></h2>
201 <table class="directive">
202 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Declare the header field which will record all intermediate IP addresses</td></tr>
203 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RemoteIPProxiesHeader <var>HeaderFieldName</var></code></td></tr>
204 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
205 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
206 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_remoteip</td></tr>
207 </table>
208     <p>The <code class="directive"><a href="#remoteipproxiesheader">RemoteIPProxiesHeader</a></code> directive specifies
209     a header into which <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> will collect a list of
210     all of the intermediate client IP addresses trusted to resolve the useragent
211     IP of the request. Note that intermediate
212     <code class="directive"><a href="#remoteiptrustedproxy">RemoteIPTrustedProxy</a></code> addresses are recorded in
213     this header, while any intermediate
214     <code class="directive"><a href="#remoteipinternalproxy">RemoteIPInternalProxy</a></code> addresses are discarded.</p>
215
216     <div class="example"><h3>Example</h3><pre class="prettyprint lang-config">RemoteIPHeader X-Forwarded-For
217 RemoteIPProxiesHeader X-Forwarded-By</pre>
218 </div>
219
220 </div>
221 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
222 <div class="directive-section"><h2><a name="RemoteIPTrustedProxy" id="RemoteIPTrustedProxy">RemoteIPTrustedProxy</a> <a name="remoteiptrustedproxy" id="remoteiptrustedproxy">Directive</a></h2>
223 <table class="directive">
224 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Restrict client IP addresses trusted to present the RemoteIPHeader value</td></tr>
225 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RemoteIPTrustedProxy <var>proxy-ip</var>|<var>proxy-ip/subnet</var>|<var>hostname</var> ...</code></td></tr>
226 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
227 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
228 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_remoteip</td></tr>
229 </table>
230     <p>The <code class="directive"><a href="#remoteiptrustedproxy">RemoteIPTrustedProxy</a></code> 
231     directive restricts which peer IP addresses (or address blocks) will be
232     trusted to present  a valid RemoteIPHeader value of the useragent IP.</p>
233   
234     <p> Unlike the <code class="directive"><a href="#remoteipinternalproxy">RemoteIPInternalProxy</a></code> directive, any intranet
235     or private IP address reported by such proxies, including the 10/8, 172.16/12,
236     192.168/16, 169.254/16 and 127/8 blocks (or outside of the IPv6 public
237     2000::/3 block) are not trusted as the useragent IP, and are left in the
238     <code class="directive"><a href="#remoteipheader">RemoteIPHeader</a></code> header's value.</p>
239
240     <div class="warning">By default, <code class="module"><a href="../mod/mod_remoteip.html">mod_remoteip</a></code> will trust 
241     all hosts presenting a non internal address in the 
242     <code class="directive"><a href="#remoteipheader">RemoteIPHeader</a></code> header value.
243     </div>
244
245     <div class="example"><h3>Trusted (Load Balancer) Example</h3><pre class="prettyprint lang-config">RemoteIPHeader X-Forwarded-For
246 RemoteIPTrustedProxy 10.0.2.16/28
247 RemoteIPTrustedProxy proxy.example.com</pre>
248 </div>
249
250 </div>
251 <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
252 <div class="directive-section"><h2><a name="RemoteIPTrustedProxyList" id="RemoteIPTrustedProxyList">RemoteIPTrustedProxyList</a> <a name="remoteiptrustedproxylist" id="remoteiptrustedproxylist">Directive</a></h2>
253 <table class="directive">
254 <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Restrict client IP addresses trusted to present the RemoteIPHeader value</td></tr>
255 <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RemoteIPTrustedProxyList <var>filename</var></code></td></tr>
256 <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
257 <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
258 <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_remoteip</td></tr>
259 </table>
260     <p>The <code class="directive"><a href="#remoteiptrustedproxylist">RemoteIPTrustedProxyList</a></code> directive specifies
261     a file parsed at startup, and builds a list of addresses (or address blocks)
262     to trust as presenting a valid RemoteIPHeader value of the useragent IP.</p>
263
264     <p>The '<code>#</code>' hash character designates a comment line, otherwise
265     each whitespace or newline separated entry is processed identically to
266     the <code class="directive"><a href="#remoteiptrustedproxy">RemoteIPTrustedProxy</a></code> directive.</p>
267
268     <div class="example"><h3>Trusted (Load Balancer) Example</h3><pre class="prettyprint lang-config">RemoteIPHeader X-Forwarded-For
269 RemoteIPTrustedProxyList conf/trusted-proxies.lst</pre>
270 </div>
271
272     <div class="example"><h3>conf/trusted-proxies.lst contents</h3><p><code>
273        # Identified external proxies;<br />
274        192.0.2.16/28         #wap phone group of proxies<br />
275        proxy.isp.example.com #some well known ISP
276     </code></p></div>
277
278 </div>
279 </div>
280 <div class="bottomlang">
281 <p><span>Available Languages: </span><a href="../en/mod/mod_remoteip.html" title="English">&nbsp;en&nbsp;</a> |
282 <a href="../fr/mod/mod_remoteip.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a></p>
283 </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
284 <script type="text/javascript"><!--//--><![CDATA[//><!--
285 var comments_shortname = 'httpd';
286 var comments_identifier = 'http://httpd.apache.org/docs/trunk/mod/mod_remoteip.html';
287 (function(w, d) {
288     if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
289         d.write('<div id="comments_thread"><\/div>');
290         var s = d.createElement('script');
291         s.type = 'text/javascript';
292         s.async = true;
293         s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
294         (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
295     }
296     else {
297         d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
298     }
299 })(window, document);
300 //--><!]]></script></div><div id="footer">
301 <p class="apache">Copyright 2016 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
302 <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/quickreference.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
303 if (typeof(prettyPrint) !== 'undefined') {
304     prettyPrint();
305 }
306 //--><!]]></script>
307 </body></html>