2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="mod_proxy.xml.meta">
25 <name>mod_proxy</name>
26 <description>Multi-protocol proxy/gateway server</description>
27 <status>Extension</status>
28 <sourcefile>mod_proxy.c</sourcefile>
29 <identifier>proxy_module</identifier>
32 <note type="warning"><title>Warning</title>
33 <p>Do not enable proxying with <directive module="mod_proxy"
34 >ProxyRequests</directive> until you have <a href="#access"
35 >secured your server</a>. Open proxy servers are dangerous both to your
36 network and to the Internet at large.</p>
39 <p><module>mod_proxy</module> and related modules implement a
40 proxy/gateway for Apache HTTP Server, supporting a number of popular
41 protocols as well as several different load balancing algorithms.
42 Third-party modules can add support for additional protocols and
43 load balancing algorithms.</p>
45 <p>A set of modules must be loaded into the server to provide the
46 necessary features. These modules can be included statically at
47 build time or dynamically via the
48 <directive module="mod_so">LoadModule</directive> directive).
49 The set must include:</p>
52 <li><module>mod_proxy</module>, which provides basic proxy
55 <li><module>mod_proxy_balancer</module> and one or more
56 balancer modules, if load balancing is required. (See
57 <module>mod_proxy_balancer</module> for more information.)</li>
59 <li>one or more proxy scheme, or protocol, modules:
62 <tr><th>Protocol</th><th>Module</th></tr>
63 <tr><td>AJP13 (Apache JServe Protocol version
64 1.3)</td><td><module>mod_proxy_ajp</module></td></tr>
66 SSL)</td><td><module>mod_proxy_connect</module></td></tr>
67 <tr><td>FastCGI</td><td><module>mod_proxy_fcgi</module></td></tr>
68 <tr><td>ftp</td><td><module>mod_proxy_ftp</module></td></tr>
69 <tr><td>HTTP/0.9, HTTP/1.0, and
70 HTTP/1.1</td><td><module>mod_proxy_http</module></td></tr>
71 <tr><td>SCGI</td><td><module>mod_proxy_scgi</module></td></tr>
76 <p>In addition, extended features are provided by other modules.
77 Caching is provided by <module>mod_cache</module> and related
78 modules. The ability to contact remote servers using the SSL/TLS
79 protocol is provided by the <code>SSLProxy*</code> directives of
80 <module>mod_ssl</module>. These additional modules will need
81 to be loaded and configured to take advantage of these features.</p>
83 <seealso><module>mod_cache</module></seealso>
84 <seealso><module>mod_proxy_ajp</module></seealso>
85 <seealso><module>mod_proxy_connect</module></seealso>
86 <seealso><module>mod_proxy_fcgi</module></seealso>
87 <seealso><module>mod_proxy_ftp</module></seealso>
88 <seealso><module>mod_proxy_http</module></seealso>
89 <seealso><module>mod_proxy_scgi</module></seealso>
90 <seealso><module>mod_proxy_balancer</module></seealso>
91 <seealso><module>mod_ssl</module></seealso>
93 <section id="forwardreverse"><title>Forward Proxies and Reverse
94 Proxies/Gateways</title>
95 <p>Apache HTTP Server can be configured in both a <dfn>forward</dfn> and
96 <dfn>reverse</dfn> proxy (also known as <dfn>gateway</dfn>) mode.</p>
98 <p>An ordinary <dfn>forward proxy</dfn> is an intermediate
99 server that sits between the client and the <em>origin
100 server</em>. In order to get content from the origin server,
101 the client sends a request to the proxy naming the origin server
102 as the target and the proxy then requests the content from the
103 origin server and returns it to the client. The client must be
104 specially configured to use the forward proxy to access other
107 <p>A typical usage of a forward proxy is to provide Internet
108 access to internal clients that are otherwise restricted by a
109 firewall. The forward proxy can also use caching (as provided
110 by <module>mod_cache</module>) to reduce network usage.</p>
112 <p>The forward proxy is activated using the <directive
113 module="mod_proxy">ProxyRequests</directive> directive. Because
114 forward proxies allow clients to access arbitrary sites through
115 your server and to hide their true origin, it is essential that
116 you <a href="#access">secure your server</a> so that only
117 authorized clients can access the proxy before activating a
120 <p>A <dfn>reverse proxy</dfn> (or <dfn>gateway</dfn>), by
121 contrast, appears to the client just like an ordinary web
122 server. No special configuration on the client is necessary.
123 The client makes ordinary requests for content in the name-space
124 of the reverse proxy. The reverse proxy then decides where to
125 send those requests, and returns the content as if it was itself
128 <p>A typical usage of a reverse proxy is to provide Internet
129 users access to a server that is behind a firewall. Reverse
130 proxies can also be used to balance load among several back-end
131 servers, or to provide caching for a slower back-end server.
132 In addition, reverse proxies can be used simply to bring
133 several servers into the same URL space.</p>
135 <p>A reverse proxy is activated using the <directive
136 module="mod_proxy">ProxyPass</directive> directive or the
137 <code>[P]</code> flag to the <directive
138 module="mod_rewrite">RewriteRule</directive> directive. It is
139 <strong>not</strong> necessary to turn <directive
140 module="mod_proxy">ProxyRequests</directive> on in order to
141 configure a reverse proxy.</p>
142 </section> <!-- /forwardreverse -->
144 <section id="examples"><title>Basic Examples</title>
146 <p>The examples below are only a very basic idea to help you
147 get started. Please read the documentation on the individual
150 <p>In addition, if you wish to have caching enabled, consult
151 the documentation from <module>mod_cache</module>.</p>
153 <example><title>Reverse Proxy</title>
154 <highlight language="config">
155 ProxyPass /foo http://foo.example.com/bar
156 ProxyPassReverse /foo http://foo.example.com/bar
160 <example><title>Forward Proxy</title>
161 <highlight language="config">
166 Require host internal.example.com
170 </section> <!-- /examples -->
173 <section id="workers"><title>Workers</title>
174 <p>The proxy manages the configuration of origin servers and their
175 communication parameters in objects called <dfn>workers</dfn>.
176 There are two built-in workers, the default forward proxy worker and the
177 default reverse proxy worker. Additional workers can be configured
180 <p>The two default workers have a fixed configuration
181 and will be used if no other worker matches the request.
182 They do not use HTTP Keep-Alive or connection pooling.
183 The TCP connections to the origin server will instead be
184 opened and closed for each request.</p>
186 <p>Explicitly configured workers are identified by their URL.
187 They are usually created and configured using
188 <directive module="mod_proxy">ProxyPass</directive> or
189 <directive module="mod_proxy">ProxyPassMatch</directive> when used
190 for a reverse proxy:</p>
192 <highlight language="config">
193 ProxyPass /example http://backend.example.com connectiontimeout=5 timeout=30
196 <p>This will create a worker associated with the origin server URL
197 <code>http://backend.example.com</code> and using the given timeout
198 values. When used in a forward proxy, workers are usually defined
199 via the <directive module="mod_proxy">ProxySet</directive> directive:</p>
201 <highlight language="config">
202 ProxySet http://backend.example.com connectiontimeout=5 timeout=30
205 <p>or alternatively using <directive module="mod_proxy">Proxy</directive>
206 and <directive module="mod_proxy">ProxySet</directive>:</p>
208 <highlight language="config">
209 <Proxy http://backend.example.com>
210 ProxySet connectiontimeout=5 timeout=30
214 <p>Using explicitly configured workers in the forward mode is
215 not very common, because forward proxies usually communicate with many
216 different origin servers. Creating explicit workers for some of the
217 origin servers can still be useful, if they are used very often.
218 Explicitly configured workers have no concept of forward or reverse
219 proxying by themselves. They encapsulate a common concept of
220 communication with origin servers. A worker created by
221 <directive module="mod_proxy">ProxyPass</directive> for use in a
222 reverse proxy will be also used for forward proxy requests whenever
223 the URL to the origin server matches the worker URL and vice versa.</p>
225 <p>The URL identifying a direct worker is the URL of its
226 origin server including any path components given:</p>
228 <highlight language="config">
229 ProxyPass /examples http://backend.example.com/examples
230 ProxyPass /docs http://backend.example.com/docs
233 <p>This example defines two different workers, each using a separate
234 connection pool and configuration.</p>
236 <note type="warning"><title>Worker Sharing</title>
237 <p>Worker sharing happens if the worker URLs overlap, which occurs when
238 the URL of some worker is a leading substring of the URL of another
239 worker defined later in the configuration file. In the following example</p>
241 <highlight language="config">
242 ProxyPass /apps http://backend.example.com/ timeout=60
243 ProxyPass /examples http://backend.example.com/examples timeout=10
246 <p>the second worker isn't actually created. Instead the first
247 worker is used. The benefit is, that there is only one connection pool,
248 so connections are more often reused. Note that all configuration attributes
249 given explicitly for the later worker will be ignored. This will be logged
250 as a warning. In the above example the resulting timeout value
251 for the URL <code>/examples</code> will be <code>60</code> instead
252 of <code>10</code>!</p>
254 <p>If you want to avoid worker sharing, sort your worker definitions
255 by URL length, starting with the longest worker URLs. If you want to maximize
256 worker sharing use the reverse sort order. See also the related warning about
257 ordering <directive module="mod_proxy">ProxyPass</directive> directives.</p>
259 </note> <!-- /worker_sharing -->
261 <p>Explicitly configured workers come in two flavors:
262 <dfn>direct workers</dfn> and <dfn>(load) balancer workers</dfn>.
263 They support many important configuration attributes which are
264 described below in the <directive module="mod_proxy">ProxyPass</directive>
265 directive. The same attributes can also be set using
266 <directive module="mod_proxy">ProxySet</directive>.</p>
268 <p>The set of options available for a direct worker
269 depends on the protocol, which is specified in the origin server URL.
270 Available protocols include <code>ajp</code>, <code>fcgi</code>,
271 <code>ftp</code>, <code>http</code> and <code>scgi</code>.</p>
273 <p>Balancer workers are virtual workers that use direct workers known
274 as their members to actually handle the requests. Each balancer can
275 have multiple members. When it handles a request, it chooses a member
276 based on the configured load balancing algorithm.</p>
278 <p>A balancer worker is created if its worker URL uses
279 <code>balancer</code> as the protocol scheme.
280 The balancer URL uniquely identifies the balancer worker.
281 Members are added to a balancer using
282 <directive module="mod_proxy">BalancerMember</directive>.</p>
284 </section> <!-- /workers -->
286 <section id="access"><title>Controlling access to your proxy</title>
287 <p>You can control who can access your proxy via the <directive
288 module="mod_proxy" type="section">Proxy</directive> control block as in
289 the following example:</p>
291 <highlight language="config">
297 <p>For more information on access control directives, see
298 <module>mod_authz_host</module>.</p>
300 <p>Strictly limiting access is essential if you are using a
301 forward proxy (using the <directive
302 module="mod_proxy">ProxyRequests</directive> directive).
303 Otherwise, your server can be used by any client to access
304 arbitrary hosts while hiding his or her true identity. This is
305 dangerous both for your network and for the Internet at large.
306 When using a reverse proxy (using the <directive
307 module="mod_proxy">ProxyPass</directive> directive with
308 <code>ProxyRequests Off</code>), access control is less
309 critical because clients can only contact the hosts that you
310 have specifically configured.</p>
312 <p><strong>See Also</strong> the <a href="mod_proxy_http.html#env"
313 >Proxy-Chain-Auth</a> environment variable.</p>
315 </section> <!-- /access -->
317 <section id="startup"><title>Slow Startup</title>
318 <p>If you're using the <directive module="mod_proxy"
319 >ProxyBlock</directive> directive, hostnames' IP addresses are looked up
320 and cached during startup for later match test. This may take a few
321 seconds (or more) depending on the speed with which the hostname lookups
323 </section> <!-- /startup -->
325 <section id="intranet"><title>Intranet Proxy</title>
326 <p>An Apache httpd proxy server situated in an intranet needs to forward
327 external requests through the company's firewall (for this, configure
328 the <directive module="mod_proxy">ProxyRemote</directive> directive
329 to forward the respective <var>scheme</var> to the firewall proxy).
330 However, when it has to
331 access resources within the intranet, it can bypass the firewall when
332 accessing hosts. The <directive module="mod_proxy">NoProxy</directive>
333 directive is useful for specifying which hosts belong to the intranet and
334 should be accessed directly.</p>
336 <p>Users within an intranet tend to omit the local domain name from their
337 WWW requests, thus requesting "http://somehost/" instead of
338 <code>http://somehost.example.com/</code>. Some commercial proxy servers
339 let them get away with this and simply serve the request, implying a
340 configured local domain. When the <directive module="mod_proxy"
341 >ProxyDomain</directive> directive is used and the server is <a
342 href="#proxyrequests">configured for proxy service</a>, Apache httpd can return
343 a redirect response and send the client to the correct, fully qualified,
344 server address. This is the preferred method since the user's bookmark
345 files will then contain fully qualified hosts.</p>
346 </section> <!-- /intranet -->
348 <section id="envsettings"><title>Protocol Adjustments</title>
349 <p>For circumstances where <module>mod_proxy</module> is sending
350 requests to an origin server that doesn't properly implement
351 keepalives or HTTP/1.1, there are two <a
352 href="../env.html">environment variables</a> that can force the
353 request to use HTTP/1.0 with no keepalive. These are set via the
354 <directive module="mod_env">SetEnv</directive> directive.</p>
356 <p>These are the <code>force-proxy-request-1.0</code> and
357 <code>proxy-nokeepalive</code> notes.</p>
359 <highlight language="config">
360 <Location /buggyappserver/>
361 ProxyPass http://buggyappserver:7001/foo/
362 SetEnv force-proxy-request-1.0 1
363 SetEnv proxy-nokeepalive 1
367 </section> <!-- /envsettings -->
369 <section id="request-bodies"><title>Request Bodies</title>
371 <p>Some request methods such as POST include a request body.
372 The HTTP protocol requires that requests which include a body
373 either use chunked transfer encoding or send a
374 <code>Content-Length</code> request header. When passing these
375 requests on to the origin server, <module>mod_proxy_http</module>
376 will always attempt to send the <code>Content-Length</code>. But
377 if the body is large and the original request used chunked
378 encoding, then chunked encoding may also be used in the upstream
379 request. You can control this selection using <a
380 href="../env.html">environment variables</a>. Setting
381 <code>proxy-sendcl</code> ensures maximum compatibility with
382 upstream servers by always sending the
383 <code>Content-Length</code>, while setting
384 <code>proxy-sendchunked</code> minimizes resource usage by using
385 chunked encoding.</p>
387 <p>Under some circumstances, the server must spool request bodies
388 to disk to satisfy the requested handling of request bodies. For
389 example, this spooling will occur if the original body was sent with
390 chunked encoding (and is large), but the administrator has
391 asked for backend requests to be sent with Content-Length or as HTTP/1.0.
392 This spooling can also occur if the request body already has a
393 Content-Length header, but the server is configured to filter incoming
396 <p><directive module="core">LimitRequestBody</directive> only applies to
397 request bodies that the server will spool to disk</p>
399 </section> <!-- /request-bodies -->
401 <section id="x-headers"><title>Reverse Proxy Request Headers</title>
403 <p>When acting in a reverse-proxy mode (using the <directive
404 module="mod_proxy">ProxyPass</directive> directive, for example),
405 <module>mod_proxy_http</module> adds several request headers in
406 order to pass information to the origin server. These headers
410 <dt><code>X-Forwarded-For</code></dt>
411 <dd>The IP address of the client.</dd>
412 <dt><code>X-Forwarded-Host</code></dt>
413 <dd>The original host requested by the client in the <code>Host</code>
414 HTTP request header.</dd>
415 <dt><code>X-Forwarded-Server</code></dt>
416 <dd>The hostname of the proxy server.</dd>
419 <p>Be careful when using these headers on the origin server, since
420 they will contain more than one (comma-separated) value if the
421 original request already contained one of these headers. For
422 example, you can use <code>%{X-Forwarded-For}i</code> in the log
423 format string of the origin server to log the original clients IP
424 address, but you may get more than one address if the request
425 passes through several proxies.</p>
427 <p>See also the <directive
428 module="mod_proxy">ProxyPreserveHost</directive> and <directive
429 module="mod_proxy">ProxyVia</directive> directives, which control
430 other request headers.</p>
432 </section> <!--/x-headers -->
435 <directivesynopsis type="section">
437 <description>Container for directives applied to proxied resources</description>
438 <syntax><Proxy <var>wildcard-url</var>> ...</Proxy></syntax>
439 <contextlist><context>server config</context><context>virtual host</context>
443 <p>Directives placed in <directive type="section">Proxy</directive>
444 sections apply only to matching proxied content. Shell-style wildcards are
447 <p>For example, the following will allow only hosts in
448 <code>yournetwork.example.com</code> to access content via your proxy
451 <highlight language="config">
453 Require host yournetwork.example.com
457 <p>The following example will process all files in the <code>foo</code>
458 directory of <code>example.com</code> through the <code>INCLUDES</code>
459 filter when they are sent through the proxy server:</p>
461 <highlight language="config">
462 <Proxy http://example.com/foo/*>
463 SetOutputFilter INCLUDES
468 <seealso><directive type="section" module="mod_proxy">ProxyMatch</directive></seealso>
472 <name>ProxyBadHeader</name>
473 <description>Determines how to handle bad header lines in a
474 response</description>
475 <syntax>ProxyBadHeader IsError|Ignore|StartBody</syntax>
476 <default>ProxyBadHeader IsError</default>
477 <contextlist><context>server config</context><context>virtual host</context>
479 <compatibility>Available in Apache HTTP Server 2.0.44 and later</compatibility>
482 <p>The <directive>ProxyBadHeader</directive> directive determines the
483 behaviour of <module>mod_proxy</module> if it receives syntactically invalid
484 response header lines (<em>i.e.</em> containing no colon) from the origin
485 server. The following arguments are possible:</p>
488 <dt><code>IsError</code></dt>
489 <dd>Abort the request and end up with a 502 (Bad Gateway) response. This is
490 the default behaviour.</dd>
492 <dt><code>Ignore</code></dt>
493 <dd>Treat bad header lines as if they weren't sent.</dd>
495 <dt><code>StartBody</code></dt>
496 <dd>When receiving the first bad header line, finish reading the headers and
497 treat the remainder as body. This helps to work around buggy backend servers
498 which forget to insert an empty line between the headers and the body.</dd>
503 <directivesynopsis type="section">
504 <name>ProxyMatch</name>
505 <description>Container for directives applied to regular-expression-matched
506 proxied resources</description>
507 <syntax><ProxyMatch <var>regex</var>> ...</ProxyMatch></syntax>
508 <contextlist><context>server config</context><context>virtual host</context>
512 <p>The <directive type="section">ProxyMatch</directive> directive is
513 identical to the <directive module="mod_proxy"
514 type="section">Proxy</directive> directive, except it matches URLs
515 using <glossary ref="regex">regular expressions</glossary>.</p>
517 <seealso><directive type="section" module="mod_proxy">Proxy</directive></seealso>
521 <name>ProxyPreserveHost</name>
522 <description>Use incoming Host HTTP request header for proxy
523 request</description>
524 <syntax>ProxyPreserveHost On|Off</syntax>
525 <default>ProxyPreserveHost Off</default>
526 <contextlist><context>server config</context><context>virtual host</context>
527 <context>directory</context>
529 <compatibility>Available in Apache HTTP Server 2.0.31 and later. Usable in directory
530 context in 2.3.3 and later.</compatibility>
533 <p>When enabled, this option will pass the Host: line from the incoming
534 request to the proxied host, instead of the hostname specified in the
535 <directive>ProxyPass</directive> line.</p>
537 <p>This option should normally be turned <code>Off</code>. It is mostly
538 useful in special configurations like proxied mass name-based virtual
539 hosting, where the original Host header needs to be evaluated by the
545 <name>ProxyRequests</name>
546 <description>Enables forward (standard) proxy requests</description>
547 <syntax>ProxyRequests On|Off</syntax>
548 <default>ProxyRequests Off</default>
549 <contextlist><context>server config</context><context>virtual host</context>
553 <p>This allows or prevents Apache httpd from functioning as a forward proxy
554 server. (Setting ProxyRequests to <code>Off</code> does not disable use of
555 the <directive module="mod_proxy">ProxyPass</directive> directive.)</p>
557 <p>In a typical reverse proxy or gateway configuration, this
558 option should be set to
559 <code>Off</code>.</p>
561 <p>In order to get the functionality of proxying HTTP or FTP sites, you
562 need also <module>mod_proxy_http</module> or <module>mod_proxy_ftp</module>
563 (or both) present in the server.</p>
565 <p>In order to get the functionality of proxying HTTPS sites, you
566 need <module>mod_proxy_connect</module> enabled in the server.</p>
568 <note type="warning"><title>Warning</title>
569 <p>Do not enable proxying with <directive
570 module="mod_proxy">ProxyRequests</directive> until you have <a
571 href="#access">secured your server</a>. Open proxy servers are dangerous
572 both to your network and to the Internet at large.</p>
575 <seealso><a href="#forwardreverse">Forward and Reverse Proxies/Gateways</a></seealso>
579 <name>ProxyRemote</name>
580 <description>Remote proxy used to handle certain requests</description>
581 <syntax>ProxyRemote <var>match</var> <var>remote-server</var></syntax>
582 <contextlist><context>server config</context><context>virtual host</context>
586 <p>This defines remote proxies to this proxy. <var>match</var> is either the
587 name of a URL-scheme that the remote server supports, or a partial URL
588 for which the remote server should be used, or <code>*</code> to indicate
589 the server should be contacted for all requests. <var>remote-server</var> is
590 a partial URL for the remote server. Syntax:</p>
593 <dfn>remote-server</dfn> =
594 <var>scheme</var>://<var>hostname</var>[:<var>port</var>]
597 <p><var>scheme</var> is effectively the protocol that should be used to
598 communicate with the remote server; only <code>http</code> and <code>https</code>
599 are supported by this module. When using <code>https</code>, the requests
600 are forwarded through the remote proxy using the HTTP CONNECT method.</p>
602 <example><title>Example</title>
603 <highlight language="config">
604 ProxyRemote http://goodguys.example.com/ http://mirrorguys.example.com:8000
605 ProxyRemote * http://cleverproxy.localdomain
606 ProxyRemote ftp http://ftpproxy.mydomain:8080
610 <p>In the last example, the proxy will forward FTP requests, encapsulated
611 as yet another HTTP proxy request, to another proxy which can handle
614 <p>This option also supports reverse proxy configuration - a backend
615 webserver can be embedded within a virtualhost URL space even if that
616 server is hidden by another forward proxy.</p>
621 <name>ProxyRemoteMatch</name>
622 <description>Remote proxy used to handle requests matched by regular
623 expressions</description>
624 <syntax>ProxyRemoteMatch <var>regex</var> <var>remote-server</var></syntax>
625 <contextlist><context>server config</context><context>virtual host</context>
629 <p>The <directive>ProxyRemoteMatch</directive> is identical to the
630 <directive module="mod_proxy">ProxyRemote</directive> directive, except the
631 first argument is a <glossary ref="regex">regular expression</glossary>
632 match against the requested URL.</p>
637 <name>BalancerGrowth</name>
638 <description>Number of additional Balancers that can be added Post-configuration</description>
639 <syntax>BalancerGrowth <var>#</var></syntax>
640 <default>BalancerGrowth 5</default>
641 <contextlist><context>server config</context><context>virtual host</context></contextlist>
642 <compatibility>BalancerGrowth is only available in Apache HTTP Server 2.3.13
643 and later.</compatibility>
645 <p>This directive allows for growth potential in the number of
646 Balancers available for a virtualhost in addition to the
647 number pre-configured. It only takes effect if there is at
648 least 1 pre-configured Balancer.</p>
653 <name>BalancerMember</name>
654 <description>Add a member to a load balancing group</description>
655 <syntax>BalancerMember [<var>balancerurl</var>] <var>url</var> [<var
656 >key=value [key=value ...]]</var></syntax>
657 <contextlist><context>directory</context>
659 <compatibility>BalancerMember is only available in Apache HTTP Server 2.2
660 and later.</compatibility>
662 <p>This directive adds a member to a load balancing group. It could be used
663 within a <code><Proxy <var>balancer://</var>...></code> container
664 directive, and can take any of the key value pair parameters available to
665 <directive module="mod_proxy">ProxyPass</directive> directives.</p>
666 <p>One additional parameter is available only to <directive
667 module="mod_proxy">BalancerMember</directive> directives:
668 <var>loadfactor</var>. This is the member load factor - a number between 1
669 (default) and 100, which defines the weighted load to be applied to the
670 member in question.</p>
671 <p>The balancerurl is only needed when not in <code><Proxy <var>balancer://</var>...></code>
672 container directive. It corresponds to the url of a balancer defined in
673 <directive module="mod_proxy">ProxyPass</directive> directive.</p>
678 <name>ProxySet</name>
679 <description>Set various Proxy balancer or member parameters</description>
680 <syntax>ProxySet <var>url</var> <var>key=value [key=value ...]</var></syntax>
681 <contextlist><context>directory</context>
683 <compatibility>ProxySet is only available in Apache HTTP Server 2.2
684 and later.</compatibility>
686 <p>This directive is used as an alternate method of setting any of the
687 parameters available to Proxy balancers and workers normally done via the
688 <directive module="mod_proxy">ProxyPass</directive> directive. If used
689 within a <code><Proxy <var>balancer url|worker url</var>></code>
690 container directive, the <var>url</var> argument is not required. As a side
691 effect the respective balancer or worker gets created. This can be useful
692 when doing reverse proxying via a
693 <directive module="mod_rewrite">RewriteRule</directive> instead of a
694 <directive module="mod_proxy">ProxyPass</directive> directive.</p>
697 <highlight language="config">
698 <Proxy balancer://hotcluster>
699 BalancerMember http://www2.example.com:8080 loadfactor=1
700 BalancerMember http://www3.example.com:8080 loadfactor=2
701 ProxySet lbmethod=bytraffic
706 <highlight language="config">
707 <Proxy http://backend>
708 ProxySet keepalive=On
712 <highlight language="config">
713 ProxySet balancer://foo lbmethod=bytraffic timeout=15
716 <highlight language="config">
717 ProxySet ajp://backend:7001 timeout=15
720 <note type="warning"><title>Warning</title>
721 <p>Keep in mind that the same parameter key can have a different meaning
722 depending whether it is applied to a balancer or a worker as shown by the two
723 examples above regarding timeout.</p>
730 <name>ProxyPass</name>
731 <description>Maps remote servers into the local server URL-space</description>
732 <syntax>ProxyPass [<var>path</var>] !|<var>url</var> [<var>key=value</var>
733 <var>[key=value</var> ...]] [nocanon] [interpolate] [noquery]</syntax>
734 <contextlist><context>server config</context><context>virtual host</context>
735 <context>directory</context>
739 <p>This directive allows remote servers to be mapped into the
740 space of the local server; the local server does not act as a
741 proxy in the conventional sense, but appears to be a mirror of the
742 remote server. The local server is often called a <dfn>reverse
743 proxy</dfn> or <dfn>gateway</dfn>. The <var>path</var> is the name of
744 a local virtual path; <var>url</var> is a partial URL for the
745 remote server and cannot include a query string.</p>
747 <note type="warning">The <directive
748 module="mod_proxy">ProxyRequests</directive> directive should
749 usually be set <strong>off</strong> when using
750 <directive>ProxyPass</directive>.</note>
752 <p>Suppose the local server has address <code>http://example.com/</code>;
755 <highlight language="config">
756 <Location /mirror/foo/>
757 ProxyPass http://backend.example.com/
761 <p>will cause a local request for
762 <code>http://example.com/mirror/foo/bar</code> to be internally converted
763 into a proxy request to <code>http://backend.example.com/bar</code>.</p>
765 <p>The following alternative syntax is possible, however it can carry a
766 performance penalty when present in very large numbers. The advantage of
767 the below syntax is that it allows for dynamic control via the
768 <a href="mod_proxy_balancer.html#balancer_manager">Balancer Manager</a> interface:</p>
770 <highlight language="config">
771 ProxyPass /mirror/foo/ http://backend.example.com/
774 <note type="warning">
775 <p>If the first argument ends with a trailing <strong>/</strong>, the second
776 argument should also end with a trailing <strong>/</strong> and vice
777 versa. Otherwise the resulting requests to the backend may miss some
778 needed slashes and do not deliver the expected results.
782 <p>The <code>!</code> directive is useful in situations where you don't want
783 to reverse-proxy a subdirectory, <em>e.g.</em></p>
785 <highlight language="config">
786 <Location /mirror/foo/>
787 ProxyPass http://backend.example.com/
789 <Location /mirror/foo/i>
794 <highlight language="config">
795 ProxyPass /mirror/foo/i !
796 ProxyPass /mirror/foo http://backend.example.com
799 <p>will proxy all requests to <code>/mirror/foo</code> to
800 <code>backend.example.com</code> <em>except</em> requests made to
801 <code>/mirror/foo/i</code>.</p>
803 <note type="warning"><title>Ordering ProxyPass Directives</title>
804 <p>The configured <directive module="mod_proxy">ProxyPass</directive>
805 and <directive module="mod_proxy">ProxyPassMatch</directive>
806 rules are checked in the order of configuration. The first rule that
807 matches wins. So usually you should sort conflicting
808 <directive module="mod_proxy">ProxyPass</directive> rules starting with the
809 longest URLs first. Otherwise later rules for longer URLS will be hidden
810 by any earlier rule which uses a leading substring of the URL. Note that
811 there is some relation with worker sharing. In contrast, only one
812 <directive module="mod_proxy">ProxyPass</directive> directive can be placed
813 in a <directive module="core">Location</directive> block, and the most
814 specific location will take precedence.</p>
816 <p>For the same reasons exclusions must come <em>before</em> the
817 general <directive>ProxyPass</directive> directives.</p>
819 </note> <!-- /ordering_proxypass -->
821 <p>In Apache HTTP Server 2.1 and later, mod_proxy supports pooled
822 connections to a backend server. Connections created on demand
823 can be retained in a pool for future use. Limits on the pool size
824 and other settings can be coded on
825 the <directive>ProxyPass</directive> directive
826 using <code>key=value</code> parameters, described in the table
829 <p>By default, mod_proxy will allow and retain the maximum number of
830 connections that could be used simultaneously by that web server child
831 process. Use the <code>max</code> parameter to reduce the number from
832 the default. Use the <code>ttl</code> parameter to set an optional
833 time to live; connections which have been unused for at least
834 <code>ttl</code> seconds will be closed. <code>ttl</code> can be used
835 to avoid using a connection which is subject to closing because of the
836 backend server's keep-alive timeout.</p>
838 <p>The pool of connections is maintained per web server child
839 process, and <code>max</code> and other settings are not coordinated
840 among all child processes, except when only one child process is allowed
841 by configuration or MPM design.</p>
843 <example><title>Example</title>
844 ProxyPass /example http://backend.example.com max=20 ttl=120 retry=300
847 <table border="2"><tr><th>BalancerMember parameters</th></tr></table>
849 <tr><th>Parameter</th>
851 <th>Description</th></tr>
854 <td>Minimum number of connection pool entries, unrelated to the
855 actual number of connections. This only needs to be modified from the
856 default for special circumstances where heap memory associated with the
857 backend connections should be preallocated or retained.</td></tr>
860 <td>Maximum number of connections that will be allowed to the
861 backend server. The default for this limit is the number of threads
862 per process in the active MPM. In the Prefork MPM, this is always 1,
863 while with other MPMs it is controlled by the
864 <directive>ThreadsPerChild</directive> directive.</td></tr>
867 <td>Retained connection pool entries above this limit are freed
868 during certain operations if they have been unused for longer than
869 the time to live, controlled by the <code>ttl</code> parameter. If
870 the connection pool entry has an associated connection, it will be
871 closed. This only needs to be modified from the default for special
872 circumstances where connection pool entries and any associated
873 connections which have exceeded the time to live need to be freed or
874 closed more aggressively.</td></tr>
877 <td>If set this will be the maximum time to wait for a free
878 connection in the connection pool, in milliseconds. If there are no free
879 connections in the pool the Apache httpd will return <code>SERVER_BUSY</code>
880 status to the client.
882 <tr><td>connectiontimeout</td>
884 <td>Connect timeout in seconds.
885 The number of seconds Apache httpd waits for the creation of a connection to
886 the backend to complete. By adding a postfix of ms the timeout can be
887 also set in milliseconds.
889 <tr><td>disablereuse</td>
891 <td>This parameter should be used when you want to force mod_proxy
892 to immediately close a connection to the backend after being used, and
893 thus, disable its persistent connection and pool for that backend.
894 This helps in various situations where a firewall between Apache
896 the backend server (regardless of protocol) tends to silently
897 drop connections or when backends themselves may be under round-
898 robin DNS. To disable connection pooling reuse,
899 set this property value to <code>On</code>.
901 <tr><td>flushpackets</td>
903 <td>Determines whether the proxy module will auto-flush the output
904 brigade after each "chunk" of data. 'off' means that it will flush
905 only when needed, 'on' means after each chunk is sent and
906 'auto' means poll/wait for a period of time and flush if
907 no input has been received for 'flushwait' milliseconds.
908 Currently this is in effect only for AJP.
910 <tr><td>flushwait</td>
912 <td>The time to wait for additional input, in milliseconds, before
913 flushing the output brigade if 'flushpackets' is 'auto'.
915 <tr><td>iobuffersize</td>
917 <td>Adjusts the size of the internal scratchpad IO buffer. This allows you
918 to override the <directive>ProxyIOBufferSize</directive> for a specific worker.
919 This must be at least 512 or set to 0 for the system default of 8192.
921 <tr><td>keepalive</td>
923 <td><p>This parameter should be used when you have a firewall between your
924 Apache httpd and the backend server, who tend to drop inactive connections.
925 This flag will tell the Operating System to send <code>KEEP_ALIVE</code>
926 messages on inactive connections and thus prevent the firewall to drop the connection.
927 To enable keepalive set this property value to <code>On</code>. </p>
928 <p>The frequency of initial and subsequent TCP keepalive probes
929 depends on global OS settings, and may be as high as 2 hours. To be useful,
930 the frequency configured in the OS must be smaller than the threshold used
935 <td>Sets the load balancer cluster set that the worker is a member
936 of. The load balancer will try all members of a lower numbered
937 lbset before trying higher numbered ones.
941 <td>Ping property tells the webserver to "test" the connection to
942 the backend before forwarding the request. For AJP, it causes
943 <module>mod_proxy_ajp</module>to send a <code>CPING</code>
944 request on the ajp13 connection (implemented on Tomcat 3.3.2+, 4.1.28+
945 and 5.0.13+). For HTTP, it causes <module>mod_proxy_http</module>
946 to send a <code>100-Continue</code> to the backend (only valid for
947 HTTP/1.1 - for non HTTP/1.1 backends, this property has no
948 effect). In both cases the parameter is the delay in seconds to wait
950 This feature has been added to avoid problems with hung and
952 This will increase the network traffic during the normal operation
953 which could be an issue, but it will lower the
954 traffic in case some of the cluster nodes are down or busy.
955 By adding a postfix of ms the delay can be also set in
958 <tr><td>receivebuffersize</td>
960 <td>Adjusts the size of the explicit (TCP/IP) network buffer size for
961 proxied connections. This allows you to override the
962 <directive>ProxyReceiveBufferSize</directive> for a specific worker.
963 This must be at least 512 or set to 0 for the system default.
965 <tr><td>redirect</td>
967 <td>Redirection Route of the worker. This value is usually
968 set dynamically to enable safe removal of the node from
969 the cluster. If set all requests without session id will be
970 redirected to the BalancerMember that has route parameter
975 <td>Connection pool worker retry timeout in seconds.
976 If the connection pool worker to the backend server is in the error state,
977 Apache httpd will not forward any requests to that server until the timeout
978 expires. This enables to shut down the backend server for maintenance,
979 and bring it back online later. A value of 0 means always retry workers
980 in an error state with no timeout.
984 <td>Route of the worker when used inside load balancer.
985 The route is a value appended to session id.
989 <td>Single letter value defining the initial status of
992 <tr><td>D: Worker is disabled and will not accept any requests.</td></tr>
993 <tr><td>S: Worker is administratively stopped.</td></tr>
994 <tr><td>I: Worker is in ignore-errors mode, and will always be considered available.</td></tr>
995 <tr><td>H: Worker is in hot-standby mode and will only be used if no other
996 viable workers are available.</td></tr>
997 <tr><td>E: Worker is in an error state.</td></tr>
998 <tr><td>N: Worker is in drain mode, and will only accept existing sticky sessions
999 destined for itself and ignore all other requests.</td></tr>
1001 can be set (which is the default) by prepending with '+' or
1002 cleared by prepending with '-'.
1003 Thus, a setting of 'S-E' sets this worker to Stopped and
1004 clears the in-error flag.
1006 <tr><td>timeout</td>
1007 <td><directive module="mod_proxy">ProxyTimeout</directive></td>
1008 <td>Connection timeout in seconds.
1009 The number of seconds Apache httpd waits for data sent by / to the backend.
1013 <td>Time to live for inactive connections and associated connection
1014 pool entries, in seconds. Once reaching this limit, a
1015 connection will not be used again; it will be closed at some
1021 <p>If the Proxy directive scheme starts with the
1022 <code>balancer://</code> (eg: <code>balancer://cluster/</code>,
1023 any path information is ignored) then a virtual worker that does not really
1024 communicate with the backend server will be created. Instead it is responsible
1025 for the management of several "real" workers. In that case the special set of
1026 parameters can be add to this virtual worker. See <module>mod_proxy_balancer</module>
1027 for more information about how the balancer works.
1029 <table border="2"><tr><th>Balancer parameters</th></tr></table>
1031 <tr><th>Parameter</th>
1033 <th>Description</th></tr>
1034 <tr><td>lbmethod</td>
1036 <td>Balancer load-balance method. Select the load-balancing scheduler
1037 method to use. Either <code>byrequests</code>, to perform weighted
1038 request counting, <code>bytraffic</code>, to perform weighted
1039 traffic byte count balancing, or <code>bybusyness</code>, to perform
1040 pending request balancing. Default is <code>byrequests</code>.
1042 <tr><td>maxattempts</td>
1043 <td>One less than the number of workers, or 1 with a single worker.</td>
1044 <td>Maximum number of failover attempts before giving up.
1046 <tr><td>nofailover</td>
1048 <td>If set to <code>On</code> the session will break if the worker is in
1049 error state or disabled. Set this value to On if backend servers do not
1050 support session replication.
1052 <tr><td>stickysession</td>
1054 <td>Balancer sticky session name. The value is usually set to something
1055 like <code>JSESSIONID</code> or <code>PHPSESSIONID</code>,
1056 and it depends on the backend application server that support sessions.
1057 If the backend application server uses different name for cookies
1058 and url encoded id (like servlet containers) use | to to separate them.
1059 The first part is for the cookie the second for the path.
1061 <tr><td>scolonpathdelim</td>
1063 <td>If set to <code>On</code> the semi-colon character ';' will be
1064 used as an additional sticky session path deliminator/separator. This
1065 is mainly used to emulate mod_jk's behavior when dealing with paths such
1066 as <code>JSESSIONID=6736bcf34;foo=aabfa</code>
1068 <tr><td>timeout</td>
1070 <td>Balancer timeout in seconds. If set this will be the maximum time
1071 to wait for a free worker. Default is not to wait.
1073 <tr><td>failonstatus</td>
1075 <td>A single or comma-separated list of HTTP status codes. If set this will
1076 force the worker into error state when the backend returns any status code
1077 in the list. Worker recovery behaves the same as other worker errors.
1080 <td><auto></td>
1081 <td>The protective nonce used in the <code>balancer-manager</code> application page.
1082 The default is to use an automatically determined UUID-based
1083 nonce, to provide for further protection for the page. If set,
1084 then the nonce is set to that value. A setting of <code>None</code>
1085 disables all nonce checking.
1086 <note><title>Note</title>
1087 <p>In addition to the nonce, the <code>balancer-manager</code> page
1088 should be protected via an ACL.</p>
1093 <td>Number of additional BalancerMembers to allow to be added
1094 to this balancer in addition to those defined at configuration.
1096 <tr><td>forcerecovery</td>
1098 <td>Force the immediate recovery of all workers without considering the
1099 retry parameter of the workers if all workers of a balancer are
1100 in error state. There might be cases where an already overloaded backend
1101 can get into deeper trouble if the recovery of all workers is enforced
1102 without considering the retry parameter of each worker. In this case
1103 set to <code>Off</code>.
1107 <p>A sample balancer setup</p>
1108 <highlight language="config">
1109 ProxyPass /special-area http://special.example.com smax=5 max=10
1110 ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On
1111 <Proxy balancer://mycluster>
1112 BalancerMember ajp://1.2.3.4:8009
1113 BalancerMember ajp://1.2.3.5:8009 loadfactor=20
1114 # Less powerful server, don't send as many requests there,
1115 BalancerMember ajp://1.2.3.6:8009 loadfactor=5
1119 <p>Setting up a hot-standby, that will only be used if no other
1120 members are available</p>
1121 <highlight language="config">
1122 ProxyPass / balancer://hotcluster/
1123 <Proxy balancer://hotcluster>
1124 BalancerMember ajp://1.2.3.4:8009 loadfactor=1
1125 BalancerMember ajp://1.2.3.5:8009 loadfactor=2
1126 # The server below is on hot standby
1127 BalancerMember ajp://1.2.3.6:8009 status=+H
1128 ProxySet lbmethod=bytraffic
1132 <p>Normally, mod_proxy will canonicalise ProxyPassed URLs.
1133 But this may be incompatible with some backends, particularly those
1134 that make use of <var>PATH_INFO</var>. The optional <var>nocanon</var>
1135 keyword suppresses this, and passes the URL path "raw" to the
1136 backend. Note that may affect the security of your backend, as it
1137 removes the normal limited protection against URL-based attacks
1138 provided by the proxy.</p>
1140 <p>The optional <var>interpolate</var> keyword (available in
1141 httpd 2.2.9 and later), in combination with
1142 <directive>ProxyPassInterpolateEnv</directive> causes the ProxyPass
1143 to interpolate environment variables, using the syntax
1144 <var>${VARNAME}</var>. Note that many of the standard CGI-derived
1145 environment variables will not exist when this interpolation happens,
1146 so you may still have to resort to <module>mod_rewrite</module>
1147 for complex rules.</p>
1149 <p>Normally, mod_proxy will include the query string when
1150 generating the <var>SCRIPT_FILENAME</var> environment variable.
1151 The optional <var>noquery</var> keyword (available in
1152 httpd 2.4.1 and later) prevents this.</p>
1154 <p>When used inside a <directive type="section" module="core"
1155 >Location</directive> section, the first argument is omitted and the local
1156 directory is obtained from the <directive type="section" module="core"
1157 >Location</directive>. The same will occur inside a
1158 <directive type="section" module="core">LocationMatch</directive> section,
1159 however ProxyPass does not interpret the regexp as such, so it is necessary
1160 to use <directive>ProxyPassMatch</directive> in this situation instead.</p>
1162 <p>This directive is not supported in <directive type="section" module="core"
1163 >Directory</directive> or <directive type="section" module="core"
1164 >Files</directive> sections.</p>
1166 <p>If you require a more flexible reverse-proxy configuration, see the
1167 <directive module="mod_rewrite">RewriteRule</directive> directive with the
1168 <code>[P]</code> flag.</p>
1171 </directivesynopsis>
1174 <name>ProxyPassMatch</name>
1175 <description>Maps remote servers into the local server URL-space using regular expressions</description>
1176 <syntax>ProxyPassMatch [<var>regex</var>] !|<var>url</var> [<var>key=value</var>
1177 <var>[key=value</var> ...]]</syntax>
1178 <contextlist><context>server config</context><context>virtual host</context>
1179 <context>directory</context>
1183 <p>This directive is equivalent to <directive module="mod_proxy">ProxyPass</directive>,
1184 but makes use of regular expressions, instead of simple prefix matching. The
1185 supplied regular expression is matched against the <var>url</var>, and if it
1186 matches, the server will substitute any parenthesized matches into the given
1187 string and use it as a new <var>url</var>.</p>
1189 <p>Suppose the local server has address <code>http://example.com/</code>;
1192 <highlight language="config">
1193 ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com$1
1196 <p>will cause a local request for
1197 <code>http://example.com/foo/bar.gif</code> to be internally converted
1198 into a proxy request to <code>http://backend.example.com/foo/bar.gif</code>.</p>
1199 <note><title>Note</title>
1200 <p>The URL argument must be parsable as a URL <em>before</em> regexp
1201 substitutions (as well as after). This limits the matches you can use.
1202 For instance, if we had used</p>
1203 <highlight language="config">
1204 ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com:8000$1
1206 <p>in our previous example, it would fail with a syntax error
1207 at server startup. This is a bug (PR 46665 in the ASF bugzilla),
1208 and the workaround is to reformulate the match:</p>
1209 <highlight language="config">
1210 ProxyPassMatch ^/(.*\.gif)$ http://backend.example.com:8000/$1
1213 <p>The <code>!</code> directive is useful in situations where you don't want
1214 to reverse-proxy a subdirectory.</p>
1216 <p>When used inside a <directive type="section" module="core"
1217 >LocationMatch</directive> section, the first argument is omitted and the
1218 regexp is obtained from the <directive type="section" module="core"
1219 >LocationMatch</directive>.</p>
1221 <p>If you require a more flexible reverse-proxy configuration, see the
1222 <directive module="mod_rewrite">RewriteRule</directive> directive with the
1223 <code>[P]</code> flag.</p>
1225 <note type="warning">
1226 <title>Security Warning</title>
1227 <p>Take care when constructing the target URL of the rule, considering
1228 the security impact from allowing the client influence over the set of
1229 URLs to which your server will act as a proxy. Ensure that the scheme
1230 and hostname part of the URL is either fixed, or does not allow the
1231 client undue influence.</p>
1234 </directivesynopsis>
1237 <name>ProxyPassReverse</name>
1238 <description>Adjusts the URL in HTTP response headers sent from a reverse
1239 proxied server</description>
1240 <syntax>ProxyPassReverse [<var>path</var>] <var>url</var>
1241 [<var>interpolate</var>]</syntax>
1242 <contextlist><context>server config</context><context>virtual host</context>
1243 <context>directory</context>
1247 <p>This directive lets Apache httpd adjust the URL in the <code>Location</code>,
1248 <code>Content-Location</code> and <code>URI</code> headers on HTTP
1249 redirect responses. This is essential when Apache httpd is used as a
1250 reverse proxy (or gateway) to avoid by-passing the reverse proxy
1251 because of HTTP redirects on the backend servers which stay behind
1252 the reverse proxy.</p>
1254 <p>Only the HTTP response headers specifically mentioned above
1255 will be rewritten. Apache httpd will not rewrite other response
1256 headers, nor will it rewrite URL references inside HTML pages.
1257 This means that if the proxied content contains absolute URL
1258 references, they will by-pass the proxy. A third-party module
1259 that will look inside the HTML and rewrite URL references is Nick
1260 Kew's <a href="http://apache.webthing.com/mod_proxy_html/"
1261 >mod_proxy_html</a>.</p>
1263 <p><var>path</var> is the name of a local virtual path. <var>url</var> is a
1264 partial URL for the remote server - the same way they are used for the
1265 <directive module="mod_proxy">ProxyPass</directive> directive.</p>
1267 <p>For example, suppose the local server has address
1268 <code>http://example.com/</code>; then</p>
1270 <highlight language="config">
1271 ProxyPass /mirror/foo/ http://backend.example.com/
1272 ProxyPassReverse /mirror/foo/ http://backend.example.com/
1273 ProxyPassReverseCookieDomain backend.example.com public.example.com
1274 ProxyPassReverseCookiePath / /mirror/foo/
1277 <p>will not only cause a local request for the
1278 <code>http://example.com/mirror/foo/bar</code> to be internally converted
1279 into a proxy request to <code>http://backend.example.com/bar</code>
1280 (the functionality <code>ProxyPass</code> provides here). It also takes care
1281 of redirects the server <code>backend.example.com</code> sends: when
1282 <code>http://backend.example.com/bar</code> is redirected by him to
1283 <code>http://backend.example.com/quux</code> Apache httpd adjusts this to
1284 <code>http://example.com/mirror/foo/quux</code> before forwarding the HTTP
1285 redirect response to the client. Note that the hostname used for
1286 constructing the URL is chosen in respect to the setting of the <directive
1287 module="core">UseCanonicalName</directive> directive.</p>
1289 <p>Note that this <directive>ProxyPassReverse</directive> directive can
1290 also be used in conjunction with the proxy pass-through feature
1291 (<code>RewriteRule ... [P]</code>) from <module>mod_rewrite</module>
1292 because it doesn't depend on a corresponding <directive module="mod_proxy"
1293 >ProxyPass</directive> directive.</p>
1295 <p>The optional <var>interpolate</var> keyword (available in
1296 httpd 2.2.9 and later), used together with
1297 <directive>ProxyPassInterpolateEnv</directive>, enables interpolation
1298 of environment variables specified using the format <var>${VARNAME}</var>.
1301 <p>When used inside a <directive type="section" module="core"
1302 >Location</directive> section, the first argument is omitted and the local
1303 directory is obtained from the <directive type="section" module="core"
1304 >Location</directive>. The same occurs inside a <directive type="section"
1305 module="core">LocationMatch</directive> section, but will probably not work as
1306 intended, as ProxyPassReverse will interpret the regexp literally as a
1307 path; if needed in this situation, specify the ProxyPassReverse outside
1308 the section, or in a separate <directive type="section" module="core"
1309 >Location</directive> section.</p>
1311 <p>This directive is not supported in <directive type="section" module="core"
1312 >Directory</directive> or <directive type="section" module="core"
1313 >Files</directive> sections.</p>
1315 </directivesynopsis>
1318 <name>ProxyPassReverseCookieDomain</name>
1319 <description>Adjusts the Domain string in Set-Cookie headers from a reverse-
1320 proxied server</description>
1321 <syntax>ProxyPassReverseCookieDomain <var>internal-domain</var>
1322 <var>public-domain</var> [<var>interpolate</var>]</syntax>
1323 <contextlist><context>server config</context><context>virtual host</context>
1324 <context>directory</context>
1327 <p>Usage is basically similar to
1328 <directive module="mod_proxy">ProxyPassReverse</directive>, but instead of
1329 rewriting headers that are a URL, this rewrites the <code>domain</code>
1330 string in <code>Set-Cookie</code> headers.</p>
1332 </directivesynopsis>
1336 <name>ProxyPassReverseCookiePath</name>
1337 <description>Adjusts the Path string in Set-Cookie headers from a reverse-
1338 proxied server</description>
1339 <syntax>ProxyPassReverseCookiePath <var>internal-path</var>
1340 <var>public-path</var> [<var>interpolate</var>]</syntax>
1341 <contextlist><context>server config</context><context>virtual host</context>
1342 <context>directory</context>
1346 Useful in conjunction with
1347 <directive module="mod_proxy">ProxyPassReverse</directive>
1348 in situations where backend URL paths are mapped to public paths on the
1349 reverse proxy. This directive rewrites the <code>path</code> string in
1350 <code>Set-Cookie</code> headers. If the beginning of the cookie path matches
1351 <var>internal-path</var>, the cookie path will be replaced with
1352 <var>public-path</var>.
1354 In the example given with
1355 <directive module="mod_proxy">ProxyPassReverse</directive>, the directive:
1357 <highlight language="config">
1358 ProxyPassReverseCookiePath / /mirror/foo/
1361 will rewrite a cookie with backend path <code>/</code> (or
1362 <code>/example</code> or, in fact, anything) to <code>/mirror/foo/</code>.
1365 </directivesynopsis>
1368 <name>ProxyBlock</name>
1369 <description>Words, hosts, or domains that are banned from being
1370 proxied</description>
1371 <syntax>ProxyBlock *|<var>word</var>|<var>host</var>|<var>domain</var>
1372 [<var>word</var>|<var>host</var>|<var>domain</var>] ...</syntax>
1373 <contextlist><context>server config</context><context>virtual host</context>
1377 <p>The <directive>ProxyBlock</directive> directive specifies a list of
1378 words, hosts and/or domains, separated by spaces. HTTP, HTTPS, and
1379 FTP document requests to sites whose names contain matched words,
1380 hosts or domains are <em>blocked</em> by the proxy server. The proxy
1381 module will also attempt to determine IP addresses of list items which
1382 may be hostnames during startup, and cache them for match test as
1383 well. That may slow down the startup time of the server.</p>
1385 <example><title>Example</title>
1386 <highlight language="config">
1387 ProxyBlock news.example.com auctions.example.com friends.example.com
1391 <p>Note that <code>example</code> would also be sufficient to match any
1394 <p>Hosts would also be matched if referenced by IP address.</p>
1396 <p>Note also that</p>
1398 <highlight language="config">
1402 <p>blocks connections to all sites.</p>
1404 </directivesynopsis>
1407 <name>ProxyReceiveBufferSize</name>
1408 <description>Network buffer size for proxied HTTP and FTP
1409 connections</description>
1410 <syntax>ProxyReceiveBufferSize <var>bytes</var></syntax>
1411 <default>ProxyReceiveBufferSize 0</default>
1412 <contextlist><context>server config</context><context>virtual host</context>
1416 <p>The <directive>ProxyReceiveBufferSize</directive> directive specifies an
1417 explicit (TCP/IP) network buffer size for proxied HTTP and FTP connections,
1418 for increased throughput. It has to be greater than <code>512</code> or set
1419 to <code>0</code> to indicate that the system's default buffer size should
1422 <example><title>Example</title>
1423 <highlight language="config">
1424 ProxyReceiveBufferSize 2048
1428 </directivesynopsis>
1431 <name>ProxyIOBufferSize</name>
1432 <description>Determine size of internal data throughput buffer</description>
1433 <syntax>ProxyIOBufferSize <var>bytes</var></syntax>
1434 <default>ProxyIOBufferSize 8192</default>
1435 <contextlist><context>server config</context><context>virtual host</context>
1439 <p>The <directive>ProxyIOBufferSize</directive> directive adjusts the size
1440 of the internal buffer, which is used as a scratchpad for the data between
1441 input and output. The size must be at least <code>512</code>.</p>
1443 <p>In almost every case there's no reason to change that value.</p>
1444 <p>If used with AJP this directive sets the maximum AJP packet size in
1445 bytes. If you change it from the default, you must also change the
1446 <code>packetSize</code> attribute of your AJP connector on the
1447 Tomcat side! The attribute <code>packetSize</code> is only available
1448 in Tomcat <code>5.5.20+</code> and <code>6.0.2+</code></p>
1449 <p>Normally it is not necessary to change the maximum packet size.
1450 Problems with the default value have been reported when sending
1451 certificates or certificate chains.</p>
1454 </directivesynopsis>
1457 <name>ProxyMaxForwards</name>
1458 <description>Maximium number of proxies that a request can be forwarded
1459 through</description>
1460 <syntax>ProxyMaxForwards <var>number</var></syntax>
1461 <default>ProxyMaxForwards -1</default>
1462 <contextlist><context>server config</context><context>virtual host</context>
1464 <compatibility>Available in Apache HTTP Server 2.0 and later;
1465 default behaviour changed in 2.2.7/2.3</compatibility>
1468 <p>The <directive>ProxyMaxForwards</directive> directive specifies the
1469 maximum number of proxies through which a request may pass, if there's no
1470 <code>Max-Forwards</code> header supplied with the request. This may
1471 be set to prevent infinite proxy loops, or a DoS attack.</p>
1473 <example><title>Example</title>
1474 <highlight language="config">
1479 <p>Note that setting <directive>ProxyMaxForwards</directive> is a
1480 violation of the HTTP/1.1 protocol (RFC2616), which forbids a Proxy
1481 setting <code>Max-Forwards</code> if the Client didn't set it.
1482 Earlier Apache httpd versions would always set it. A negative
1483 <directive>ProxyMaxForwards</directive> value, including the
1484 default -1, gives you protocol-compliant behaviour, but may
1485 leave you open to loops.</p>
1487 </directivesynopsis>
1490 <name>NoProxy</name>
1491 <description>Hosts, domains, or networks that will be connected to
1492 directly</description>
1493 <syntax>NoProxy <var>host</var> [<var>host</var>] ...</syntax>
1494 <contextlist><context>server config</context><context>virtual host</context>
1498 <p>This directive is only useful for Apache httpd proxy servers within
1499 intranets. The <directive>NoProxy</directive> directive specifies a
1500 list of subnets, IP addresses, hosts and/or domains, separated by
1501 spaces. A request to a host which matches one or more of these is
1502 always served directly, without forwarding to the configured
1503 <directive module="mod_proxy">ProxyRemote</directive> proxy server(s).</p>
1505 <example><title>Example</title>
1506 <highlight language="config">
1507 ProxyRemote * http://firewall.example.com:81
1508 NoProxy .example.com 192.168.112.0/21
1512 <p>The <var>host</var> arguments to the <directive>NoProxy</directive>
1513 directive are one of the following type list:</p>
1516 <!-- ===================== Domain ======================= -->
1517 <dt><var><a name="domain" id="domain">Domain</a></var></dt>
1519 <p>A <dfn>Domain</dfn> is a partially qualified DNS domain name, preceded
1520 by a period. It represents a list of hosts which logically belong to the
1521 same DNS domain or zone (<em>i.e.</em>, the suffixes of the hostnames are
1522 all ending in <var>Domain</var>).</p>
1524 <example><title>Examples</title>
1528 <p>To distinguish <var>Domain</var>s from <var><a href="#hostname"
1529 >Hostname</a></var>s (both syntactically and semantically; a DNS domain can
1530 have a DNS A record, too!), <var>Domain</var>s are always written with a
1533 <note><title>Note</title>
1534 <p>Domain name comparisons are done without regard to the case, and
1535 <var>Domain</var>s are always assumed to be anchored in the root of the
1536 DNS tree, therefore two domains <code>.ExAmple.com</code> and
1537 <code>.example.com.</code> (note the trailing period) are considered
1538 equal. Since a domain comparison does not involve a DNS lookup, it is much
1539 more efficient than subnet comparison.</p>
1542 <!-- ===================== SubNet ======================= -->
1543 <dt><var><a name="subnet" id="subnet">SubNet</a></var></dt>
1545 <p>A <dfn>SubNet</dfn> is a partially qualified internet address in
1546 numeric (dotted quad) form, optionally followed by a slash and the netmask,
1547 specified as the number of significant bits in the <var>SubNet</var>. It is
1548 used to represent a subnet of hosts which can be reached over a common
1549 network interface. In the absence of the explicit net mask it is assumed
1550 that omitted (or zero valued) trailing digits specify the mask. (In this
1551 case, the netmask can only be multiples of 8 bits wide.) Examples:</p>
1554 <dt><code>192.168</code> or <code>192.168.0.0</code></dt>
1555 <dd>the subnet 192.168.0.0 with an implied netmask of 16 valid bits
1556 (sometimes used in the netmask form <code>255.255.0.0</code>)</dd>
1557 <dt><code>192.168.112.0/21</code></dt>
1558 <dd>the subnet <code>192.168.112.0/21</code> with a netmask of 21
1559 valid bits (also used in the form <code>255.255.248.0</code>)</dd>
1562 <p>As a degenerate case, a <em>SubNet</em> with 32 valid bits is the
1563 equivalent to an <var><a href="#ipaddr">IPAddr</a></var>, while a <var>SubNet</var> with zero
1564 valid bits (<em>e.g.</em>, 0.0.0.0/0) is the same as the constant
1565 <var>_Default_</var>, matching any IP address.</p></dd>
1567 <!-- ===================== IPAddr ======================= -->
1568 <dt><var><a name="ipaddr" id="ipaddr">IPAddr</a></var></dt>
1570 <p>A <dfn>IPAddr</dfn> represents a fully qualified internet address in
1571 numeric (dotted quad) form. Usually, this address represents a host, but
1572 there need not necessarily be a DNS domain name connected with the
1574 <example><title>Example</title>
1578 <note><title>Note</title>
1579 <p>An <var>IPAddr</var> does not need to be resolved by the DNS system, so
1580 it can result in more effective apache performance.</p>
1583 <!-- ===================== Hostname ======================= -->
1584 <dt><var><a name="hostname" id="hostname">Hostname</a></var></dt>
1586 <p>A <dfn>Hostname</dfn> is a fully qualified DNS domain name which can
1587 be resolved to one or more <var><a href="#ipaddr">IPAddrs</a></var> via the
1588 DNS domain name service. It represents a logical host (in contrast to
1589 <var><a href="#domain">Domain</a></var>s, see above) and must be resolvable
1590 to at least one <var><a href="#ipaddr">IPAddr</a></var> (or often to a list
1591 of hosts with different <var><a href="#ipaddr">IPAddr</a></var>s).</p>
1593 <example><title>Examples</title>
1594 prep.ai.example.edu<br />
1598 <note><title>Note</title>
1599 <p>In many situations, it is more effective to specify an <var><a
1600 href="#ipaddr">IPAddr</a></var> in place of a <var>Hostname</var> since a
1601 DNS lookup can be avoided. Name resolution in Apache httpd can take a remarkable
1602 deal of time when the connection to the name server uses a slow PPP
1604 <p><var>Hostname</var> comparisons are done without regard to the case,
1605 and <var>Hostname</var>s are always assumed to be anchored in the root
1606 of the DNS tree, therefore two hosts <code>WWW.ExAmple.com</code>
1607 and <code>www.example.com.</code> (note the trailing period) are
1608 considered equal.</p>
1612 <seealso><a href="../dns-caveats.html">DNS Issues</a></seealso>
1613 </directivesynopsis>
1616 <name>ProxyTimeout</name>
1617 <description>Network timeout for proxied requests</description>
1618 <syntax>ProxyTimeout <var>seconds</var></syntax>
1619 <default>Value of <directive module="core">Timeout</directive></default>
1620 <contextlist><context>server config</context><context>virtual host</context>
1622 <compatibility>Available in Apache HTTP Server 2.0.31 and later</compatibility>
1625 <p>This directive allows a user to specifiy a timeout on proxy requests.
1626 This is useful when you have a slow/buggy appserver which hangs, and you
1627 would rather just return a timeout and fail gracefully instead of waiting
1628 however long it takes the server to return.</p>
1630 </directivesynopsis>
1633 <name>ProxyDomain</name>
1634 <description>Default domain name for proxied requests</description>
1635 <syntax>ProxyDomain <var>Domain</var></syntax>
1636 <contextlist><context>server config</context><context>virtual host</context>
1640 <p>This directive is only useful for Apache httpd proxy servers within
1641 intranets. The <directive>ProxyDomain</directive> directive specifies
1642 the default domain which the apache proxy server will belong to. If a
1643 request to a host without a domain name is encountered, a redirection
1644 response to the same host with the configured <var>Domain</var> appended
1645 will be generated.</p>
1647 <example><title>Example</title>
1648 <highlight language="config">
1649 ProxyRemote * http://firewall.example.com:81<br />
1650 NoProxy .example.com 192.168.112.0/21<br />
1651 ProxyDomain .example.com
1655 </directivesynopsis>
1658 <name>ProxyVia</name>
1659 <description>Information provided in the <code>Via</code> HTTP response
1660 header for proxied requests</description>
1661 <syntax>ProxyVia On|Off|Full|Block</syntax>
1662 <default>ProxyVia Off</default>
1663 <contextlist><context>server config</context><context>virtual host</context>
1667 <p>This directive controls the use of the <code>Via:</code> HTTP
1668 header by the proxy. Its intended use is to control the flow of
1669 proxy requests along a chain of proxy servers. See <a
1670 href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> (HTTP/1.1), section
1671 14.45 for an explanation of <code>Via:</code> header lines.</p>
1674 <li>If set to <code>Off</code>, which is the default, no special processing
1675 is performed. If a request or reply contains a <code>Via:</code> header,
1676 it is passed through unchanged.</li>
1678 <li>If set to <code>On</code>, each request and reply will get a
1679 <code>Via:</code> header line added for the current host.</li>
1681 <li>If set to <code>Full</code>, each generated <code>Via:</code> header
1682 line will additionally have the Apache httpd server version shown as a
1683 <code>Via:</code> comment field.</li>
1685 <li>If set to <code>Block</code>, every proxy request will have all its
1686 <code>Via:</code> header lines removed. No new <code>Via:</code> header will
1690 </directivesynopsis>
1693 <name>ProxyErrorOverride</name>
1694 <description>Override error pages for proxied content</description>
1695 <syntax>ProxyErrorOverride On|Off</syntax>
1696 <default>ProxyErrorOverride Off</default>
1697 <contextlist><context>server config</context><context>virtual host</context>
1698 <context>directory</context>
1700 <compatibility>Available in version 2.0 and later</compatibility>
1703 <p>This directive is useful for reverse-proxy setups, where you want to
1704 have a common look and feel on the error pages seen by the end user.
1705 This also allows for included files (via
1706 <module>mod_include</module>'s SSI) to get
1707 the error code and act accordingly (default behavior would display
1708 the error page of the proxied server, turning this on shows the SSI
1711 <p>This directive does not affect the processing of informational (1xx),
1712 normal success (2xx), or redirect (3xx) responses.</p>
1714 </directivesynopsis>
1717 <name>ProxyPassInterpolateEnv</name>
1718 <description>Enable Environment Variable interpolation in Reverse Proxy configurations</description>
1719 <syntax>ProxyPassInterpolateEnv On|Off</syntax>
1720 <default>ProxyPassInterpolateEnv Off</default>
1721 <contextlist><context>server config</context>
1722 <context>virtual host</context>
1723 <context>directory</context>
1725 <compatibility>Available in httpd 2.2.9 and later</compatibility>
1728 <p>This directive, together with the <var>interpolate</var> argument to
1729 <directive>ProxyPass</directive>, <directive>ProxyPassReverse</directive>,
1730 <directive>ProxyPassReverseCookieDomain</directive> and
1731 <directive>ProxyPassReverseCookiePath</directive>
1732 enables reverse proxies to be dynamically
1733 configured using environment variables, which may be set by
1734 another module such as <module>mod_rewrite</module>.
1735 It affects the <directive>ProxyPass</directive>,
1736 <directive>ProxyPassReverse</directive>,
1737 <directive>ProxyPassReverseCookieDomain</directive>, and
1738 <directive>ProxyPassReverseCookiePath</directive> directives,
1739 and causes them to substitute the value of an environment
1740 variable <code>varname</code> for the string <code>${varname}</code>
1741 in configuration directives (if the <var>interpolate</var> option is set).</p>
1742 <p>Keep this turned off (for server performance) unless you need it!</p>
1744 </directivesynopsis>
1747 <name>ProxyStatus</name>
1748 <description>Show Proxy LoadBalancer status in mod_status</description>
1749 <syntax>ProxyStatus Off|On|Full</syntax>
1750 <default>ProxyStatus Off</default>
1751 <contextlist><context>server config</context>
1752 <context>virtual host</context>
1754 <compatibility>Available in version 2.2 and later</compatibility>
1757 <p>This directive determines whether or not proxy
1758 loadbalancer status data is displayed via the <module>mod_status</module>
1759 server-status page.</p>
1760 <note><title>Note</title>
1761 <p><strong>Full</strong> is synonymous with <strong>On</strong></p>
1765 </directivesynopsis>
1768 <name>ProxyAddHeaders</name>
1769 <description>Add proxy information in X-Forwarded-* headers</description>
1770 <syntax>ProxyAddHeaders Off|On</syntax>
1771 <default>ProxyAddHeaders On</default>
1772 <contextlist><context>server config</context>
1773 <context>virtual host</context>
1774 <context>directory</context>
1776 <compatibility>Available in version 2.3.10 and later</compatibility>
1779 <p>This directive determines whether or not proxy related information should be passed to the
1780 backend server through X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Server HTTP headers.</p>
1781 <note><title>Effectiveness</title>
1782 <p>This option is of use only for HTTP proxying, as handled by <module>mod_proxy_http</module>.</p>
1785 </directivesynopsis>
1788 <name>ProxySourceAddress</name>
1789 <description>Set local IP address for outgoing proxy connections</description>
1790 <syntax>ProxySourceAddress <var>address</var></syntax>
1791 <contextlist><context>server config</context>
1792 <context>virtual host</context>
1794 <compatibility>Available in version 2.3.9 and later</compatibility>
1797 <p>This directive allows to set a specific local address to bind to when connecting
1798 to a backend server.</p>
1800 </directivesynopsis>