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>HTTP/1.1 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>This module implements a proxy/gateway for Apache. It implements
40 proxying capability for <code>AJP13</code> (Apache JServe Protocol
41 version 1.3), <code>FTP</code>, <code>CONNECT</code> (for SSL),
42 <code>HTTP/0.9</code>, <code>HTTP/1.0</code>, and <code>HTTP/1.1</code>.
43 The module can be configured to connect to other proxy modules for these
44 and other protocols.</p>
46 <p>Apache's proxy features are divided into several modules in
47 addition to <module>mod_proxy</module>:
48 <module>mod_proxy_http</module>, <module>mod_proxy_ftp</module>,
49 <module>mod_proxy_ajp</module>, <module>mod_proxy_balancer</module>,
50 and <module>mod_proxy_connect</module>. Thus, if you want to use
51 one or more of the particular proxy functions, load
52 <module>mod_proxy</module> <em>and</em> the appropriate module(s)
53 into the server (either statically at compile-time or dynamically
54 via the <directive module="mod_so">LoadModule</directive>
57 <p>In addition, extended features are provided by other modules.
58 Caching is provided by <module>mod_cache</module> and related
59 modules. The ability to contact remote servers using the SSL/TLS
60 protocol is provided by the <code>SSLProxy*</code> directives of
61 <module>mod_ssl</module>. These additional modules will need
62 to be loaded and configured to take advantage of these features.</p>
64 <seealso><module>mod_cache</module></seealso>
65 <seealso><module>mod_proxy_http</module></seealso>
66 <seealso><module>mod_proxy_ftp</module></seealso>
67 <seealso><module>mod_proxy_connect</module></seealso>
68 <seealso><module>mod_proxy_balancer</module></seealso>
69 <seealso><module>mod_ssl</module></seealso>
71 <section id="forwardreverse"><title>Forward and Reverse Proxies</title>
72 <p>Apache can be configured in both a <dfn>forward</dfn> and
73 <dfn>reverse</dfn> proxy mode.</p>
75 <p>An ordinary <dfn>forward proxy</dfn> is an intermediate
76 server that sits between the client and the <em>origin
77 server</em>. In order to get content from the origin server,
78 the client sends a request to the proxy naming the origin server
79 as the target and the proxy then requests the content from the
80 origin server and returns it to the client. The client must be
81 specially configured to use the forward proxy to access other
84 <p>A typical usage of a forward proxy is to provide Internet
85 access to internal clients that are otherwise restricted by a
86 firewall. The forward proxy can also use caching (as provided
87 by <module>mod_cache</module>) to reduce network usage.</p>
89 <p>The forward proxy is activated using the <directive
90 module="mod_proxy">ProxyRequests</directive> directive. Because
91 forward proxys allow clients to access arbitrary sites through
92 your server and to hide their true origin, it is essential that
93 you <a href="#access">secure your server</a> so that only
94 authorized clients can access the proxy before activating a
97 <p>A <dfn>reverse proxy</dfn>, by contrast, appears to the
98 client just like an ordinary web server. No special
99 configuration on the client is necessary. The client makes
100 ordinary requests for content in the name-space of the reverse
101 proxy. The reverse proxy then decides where to send those
102 requests, and returns the content as if it was itself the
105 <p>A typical usage of a reverse proxy is to provide Internet
106 users access to a server that is behind a firewall. Reverse
107 proxies can also be used to balance load among several back-end
108 servers, or to provide caching for a slower back-end server.
109 In addition, reverse proxies can be used simply to bring
110 several servers into the same URL space.</p>
112 <p>A reverse proxy is activated using the <directive
113 module="mod_proxy">ProxyPass</directive> directive or the
114 <code>[P]</code> flag to the <directive
115 module="mod_rewrite">RewriteRule</directive> directive. It is
116 <strong>not</strong> necessary to turn <directive
117 module="mod_proxy">ProxyRequests</directive> on in order to
118 configure a reverse proxy.</p>
119 </section> <!-- /forwardreverse -->
121 <section id="examples"><title>Basic Examples</title>
123 <p>The examples below are only a very basic idea to help you
124 get started. Please read the documentation on the individual
127 <p>In addition, if you wish to have caching enabled, consult
128 the documentation from <module>mod_cache</module>.</p>
130 <example><title>Forward Proxy</title>
131 ProxyRequests On<br />
134 <Proxy *><br />
136 Order deny,allow<br />
138 Allow from internal.example.com<br />
143 <example><title>Reverse Proxy</title>
144 ProxyRequests Off<br />
146 <Proxy *><br />
148 Order deny,allow<br />
153 ProxyPass /foo http://foo.example.com/bar<br />
154 ProxyPassReverse /foo http://foo.example.com/bar
156 </section> <!-- /examples -->
159 <section id="access"><title>Controlling access to your proxy</title>
160 <p>You can control who can access your proxy via the <directive
161 module="mod_proxy" type="section">Proxy</directive> control block as in
162 the following example:</p>
165 <Proxy *><br />
167 Order Deny,Allow<br />
169 Allow from 192.168.0<br />
174 <p>For more information on access control directives, see
175 <module>mod_authz_host</module>.</p>
177 <p>Strictly limiting access is essential if you are using a
178 forward proxy (using the <directive
179 module="mod_proxy">ProxyRequests</directive> directive).
180 Otherwise, your server can be used by any client to access
181 arbitrary hosts while hiding his or her true identity. This is
182 dangerous both for your network and for the Internet at large.
183 When using a reverse proxy (using the <directive
184 module="mod_proxy">ProxyPass</directive> directive with
185 <code>ProxyRequests Off</code>), access control is less
186 critical because clients can only contact the hosts that you
187 have specifically configured.</p>
189 </section> <!-- /access -->
191 <section id="startup"><title>Slow Startup</title>
192 <p>If you're using the <directive module="mod_proxy"
193 >ProxyBlock</directive> directive, hostnames' IP addresses are looked up
194 and cached during startup for later match test. This may take a few
195 seconds (or more) depending on the speed with which the hostname lookups
197 </section> <!-- /startup -->
199 <section id="intranet"><title>Intranet Proxy</title>
200 <p>An Apache proxy server situated in an intranet needs to forward
201 external requests through the company's firewall (for this, configure
202 the <directive module="mod_proxy">ProxyRemote</directive> directive
203 to forward the respective <var>scheme</var> to the firewall proxy).
204 However, when it has to
205 access resources within the intranet, it can bypass the firewall when
206 accessing hosts. The <directive module="mod_proxy">NoProxy</directive>
207 directive is useful for specifying which hosts belong to the intranet and
208 should be accessed directly.</p>
210 <p>Users within an intranet tend to omit the local domain name from their
211 WWW requests, thus requesting "http://somehost/" instead of
212 <code>http://somehost.example.com/</code>. Some commercial proxy servers
213 let them get away with this and simply serve the request, implying a
214 configured local domain. When the <directive module="mod_proxy"
215 >ProxyDomain</directive> directive is used and the server is <a
216 href="#proxyrequests">configured for proxy service</a>, Apache can return
217 a redirect response and send the client to the correct, fully qualified,
218 server address. This is the preferred method since the user's bookmark
219 files will then contain fully qualified hosts.</p>
220 </section> <!-- /intranet -->
222 <section id="envsettings"><title>Protocol Adjustments</title>
223 <p>For circumstances where <module>mod_proxy</module> is sending
224 requests to an origin server that doesn't properly implement
225 keepalives or HTTP/1.1, there are two <a
226 href="../env.html">environment variables</a> that can force the
227 request to use HTTP/1.0 with no keepalive. These are set via the
228 <directive module="mod_env">SetEnv</directive> directive.</p>
230 <p>These are the <code>force-proxy-request-1.0</code> and
231 <code>proxy-nokeepalive</code> notes.</p>
234 <Location /buggyappserver/><br />
236 ProxyPass http://buggyappserver:7001/foo/<br />
237 SetEnv force-proxy-request-1.0 1<br />
238 SetEnv proxy-nokeepalive 1<br />
243 </section> <!-- /envsettings -->
245 <section id="request-bodies"><title>Request Bodys</title>
247 <p>Some request methods such as POST include a request body.
248 The HTTP protocol requires that requests which include a body
249 either use chunked transfer encoding or send a
250 <code>Content-Length</code> request header. When passing these
251 requests on to the origin server, <module>mod_proxy_http</module>
252 will always attempt to send the <code>Content-Length</code>. But
253 if the body is large and the original request used chunked
254 encoding, then chunked encoding may also be used in the upstream
255 request. You can control this selection using <a
256 href="../env.html">environment variables</a>. Setting
257 <code>proxy-sendcl</code> ensures maximum compatibility with
258 upstream servers by always sending the
259 <code>Content-Length</code>, while setting
260 <code>proxy-sendchunked</code> minimizes resource usage by using
261 chunked encoding.</p>
263 </section> <!-- /request-bodies -->
265 <directivesynopsis type="section">
267 <description>Container for directives applied to proxied resources</description>
268 <syntax><Proxy <var>wildcard-url</var>> ...</Proxy></syntax>
269 <contextlist><context>server config</context><context>virtual host</context>
273 <p>Directives placed in <directive type="section">Proxy</directive>
274 sections apply only to matching proxied content. Shell-style wildcards are
277 <p>For example, the following will allow only hosts in
278 <code>yournetwork.example.com</code> to access content via your proxy
282 <Proxy *><br />
284 Order Deny,Allow<br />
286 Allow from yournetwork.example.com<br />
291 <p>The following example will process all files in the <code>foo</code>
292 directory of <code>example.com</code> through the <code>INCLUDES</code>
293 filter when they are sent through the proxy server:</p>
296 <Proxy http://example.com/foo/*><br />
298 SetOutputFilter INCLUDES<br />
307 <name>ProxyBadHeader</name>
308 <description>Determines how to handle bad header lines in a
309 response</description>
310 <syntax>ProxyBadHeader IsError|Ignore|StartBody</syntax>
311 <default>ProxyBadHeader IsError</default>
312 <contextlist><context>server config</context><context>virtual host</context>
314 <compatibility>available in Apache 2.0.44 and later</compatibility>
317 <p>The <directive>ProxyBadHeader</directive> directive determines the
318 behaviour of <module>mod_proxy</module> if it receives syntactically invalid
319 header lines (<em>i.e.</em> containing no colon). The following arguments
323 <dt><code>IsError</code></dt>
324 <dd>Abort the request and end up with a 502 (Bad Gateway) response. This is
325 the default behaviour.</dd>
327 <dt><code>Ignore</code></dt>
328 <dd>Treat bad header lines as if they weren't sent.</dd>
330 <dt><code>StartBody</code></dt>
331 <dd>When receiving the first bad header line, finish reading the headers and
332 treat the remainder as body. This helps to work around buggy backend servers
333 which forget to insert an empty line between the headers and the body.</dd>
338 <directivesynopsis type="section">
339 <name>ProxyMatch</name>
340 <description>Container for directives applied to regular-expression-matched
341 proxied resources</description>
342 <syntax><ProxyMatch <var>regex</var>> ...</ProxyMatch></syntax>
343 <contextlist><context>server config</context><context>virtual host</context>
347 <p>The <directive type="section">ProxyMatch</directive> directive is
348 identical to the <directive module="mod_proxy"
349 type="section">Proxy</directive> directive, except it matches URLs
350 using <glossary ref="regex">regular expressions</glossary>.</p>
355 <name>ProxyPreserveHost</name>
356 <description>Use incoming Host HTTP request header for proxy
357 request</description>
358 <syntax>ProxyPreserveHost On|Off</syntax>
359 <default>ProxyPreserveHost Off</default>
360 <contextlist><context>server config</context><context>virtual host</context>
362 <compatibility>Available in Apache 2.0.31 and later.</compatibility>
365 <p>When enabled, this option will pass the Host: line from the incoming
366 request to the proxied host, instead of the hostname specified in the
367 <directive>ProxyPass</directive> line.</p>
369 <p>This option should normally be turned <code>Off</code>. It is mostly
370 useful in special configurations like proxied mass name-based virtual
371 hosting, where the original Host header needs to be evaluated by the
377 <name>ProxyRequests</name>
378 <description>Enables forward (standard) proxy requests</description>
379 <syntax>ProxyRequests On|Off</syntax>
380 <default>ProxyRequests Off</default>
381 <contextlist><context>server config</context><context>virtual host</context>
385 <p>This allows or prevents Apache from functioning as a forward proxy
386 server. (Setting ProxyRequests to <code>Off</code> does not disable use of
387 the <directive module="mod_proxy">ProxyPass</directive> directive.)</p>
389 <p>In a typical reverse proxy configuration, this option should be set to
390 <code>Off</code>.</p>
392 <p>In order to get the functionality of proxying HTTP or FTP sites, you
393 need also <module>mod_proxy_http</module> or <module>mod_proxy_ftp</module>
394 (or both) present in the server.</p>
396 <note type="warning"><title>Warning</title>
397 <p>Do not enable proxying with <directive
398 module="mod_proxy">ProxyRequests</directive> until you have <a
399 href="#access">secured your server</a>. Open proxy servers are dangerous
400 both to your network and to the Internet at large.</p>
406 <name>ProxyRemote</name>
407 <description>Remote proxy used to handle certain requests</description>
408 <syntax>ProxyRemote <var>match</var> <var>remote-server</var></syntax>
409 <contextlist><context>server config</context><context>virtual host</context>
413 <p>This defines remote proxies to this proxy. <var>match</var> is either the
414 name of a URL-scheme that the remote server supports, or a partial URL
415 for which the remote server should be used, or <code>*</code> to indicate
416 the server should be contacted for all requests. <var>remote-server</var> is
417 a partial URL for the remote server. Syntax:</p>
420 <dfn>remote-server</dfn> =
421 <var>scheme</var>://<var>hostname</var>[:<var>port</var>]
424 <p><var>scheme</var> is effectively the protocol that should be used to
425 communicate with the remote server; only <code>http</code> is supported by
428 <example><title>Example</title>
429 ProxyRemote http://goodguys.com/ http://mirrorguys.com:8000<br />
430 ProxyRemote * http://cleversite.com<br />
431 ProxyRemote ftp http://ftpproxy.mydomain.com:8080
434 <p>In the last example, the proxy will forward FTP requests, encapsulated
435 as yet another HTTP proxy request, to another proxy which can handle
438 <p>This option also supports reverse proxy configuration - a backend
439 webserver can be embedded within a virtualhost URL space even if that
440 server is hidden by another forward proxy.</p>
445 <name>ProxyRemoteMatch</name>
446 <description>Remote proxy used to handle requests matched by regular
447 expressions</description>
448 <syntax>ProxyRemoteMatch <var>regex</var> <var>remote-server</var></syntax>
449 <contextlist><context>server config</context><context>virtual host</context>
453 <p>The <directive>ProxyRemoteMatch</directive> is identical to the
454 <directive module="mod_proxy">ProxyRemote</directive> directive, except the
455 first argument is a <glossary ref="regex">regular expression</glossary>
456 match against the requested URL.</p>
461 <name>BalancerMember</name>
462 <description>Add a member to a load balancing group</description>
463 <syntax>BalancerMember <var>url</var> [<var
464 >key=value [key=value ...]]</var></syntax>
465 <contextlist><context>directory</context>
467 <compatibility>BalancerMember is only available in Apache 2.2.0
468 and later.</compatibility>
470 <p>This directive adds a member to a load balancing group. It must be used
471 within a <code><Proxy <var>balancer://</var>...></code> container
472 directive, and can take any of the parameters available to
473 <directive module="mod_proxy">ProxyPass</directive> directives.</p>
474 <p>One additional parameter is available only to <directive
475 module="mod_proxy">BalancerMember</directive> directives:
476 <var>loadfactor</var>. This is the member load factor - a number between 1
477 (default) and 100, which defines the weighted load to be applied to the
478 member in question.</p>
483 <name>ProxyPass</name>
484 <description>Maps remote servers into the local server URL-space</description>
485 <syntax>ProxyPass [<var>path</var>] !|<var>url</var> [<var>key=value</var>
486 <var>[key=value</var> ...]]</syntax>
487 <contextlist><context>server config</context><context>virtual host</context>
488 <context>directory</context>
492 <p>This directive allows remote servers to be mapped into the space of
493 the local server; the local server does not act as a proxy in the
494 conventional sense, but appears to be a mirror of the remote
495 server. <var>path</var> is the name of a local virtual path; <var>url</var>
496 is a partial URL for the remote server and cannot include a query
499 <note type="warning">The <directive
500 module="mod_proxy">ProxyRequests</directive> directive should
501 usually be set <strong>off</strong> when using
502 <directive>ProxyPass</directive>.</note>
504 <p>Suppose the local server has address <code>http://example.com/</code>;
508 ProxyPass /mirror/foo/ http://backend.example.com/
511 <p>will cause a local request for
512 <code>http://example.com/mirror/foo/bar</code> to be internally converted
513 into a proxy request to <code>http://backend.example.com/bar</code>.</p>
515 <note type="warning">
516 <p>If the first argument ends with a trailing <strong>/</strong>, the second
517 argument should also end with a trailing <strong>/</strong> and vice
518 versa. Otherwise the resulting requests to the backend may miss some
519 needed slashes and do not deliver the expected results.
523 <p>The <code>!</code> directive is useful in situations where you don't want
524 to reverse-proxy a subdirectory, <em>e.g.</em></p>
527 ProxyPass /mirror/foo/i !<br />
528 ProxyPass /mirror/foo http://backend.example.com
531 <p>will proxy all requests to <code>/mirror/foo</code> to
532 <code>backend.example.com</code> <em>except</em> requests made to
533 <code>/mirror/foo/i</code>.</p>
535 <note><title>Note</title>
536 <p>Order is important. you need to put the exclusions <em>before</em> the
537 general <directive>ProxyPass</directive> directive.</p>
540 <p>As of Apache 2.1, the ability to use pooled connections to a backend
541 server is available. Using the <code>key=value</code> parameters it is
542 possible to tune this connection pooling. The default for a <code>Hard
543 Maximum</code> for the number of connections is the number of threads per
544 process in the active MPM. In the Prefork MPM, this is always 1, while with
545 the Worker MPM it is controlled by the
546 <directive>ThreadsPerChild</directive>.</p>
548 <p>Setting <code>min</code> will determine how many connections will always
549 be open to the backend server. Upto the Soft Maximum or <code>smax</code>
550 number of connections will be created on demand. Any connections above
551 <code>smax</code> are subject to a time to live or <code>ttl</code>. Apache
552 will never create more than the Hard Maximum or <code>max</code> connections
553 to the backend server.</p>
556 ProxyPass /example http://backend.example.com smax=5 max=20 ttl=120 retry=300
560 <tr><th>Parameter</th>
562 <th>Description</th></tr>
565 <td>Minimum number of connections that will always
566 be open to the backend server.</td></tr>
569 <td>Hard Maximum number of connections that will be
570 allowed to the backend server. The default for a Hard Maximum
571 for the number of connections is the number of threads per process in the
572 active MPM. In the Prefork MPM, this is always 1, while with the Worker MPM
573 it is controlled by the <directive>ThreadsPerChild</directive>.
574 Apache will never create more than the Hard Maximum connections
575 to the backend server.</td></tr>
578 <td>Upto the Soft Maximum
579 number of connections will be created on demand. Any connections above
580 <code>smax</code> are subject to a time to live or <code>ttl</code>.
584 <td>If set this will be the maximum time to wait for a free
585 connection in the connection pool. If there are no free connections
586 in the pool the Apache will return <code>SERVER_BUSY</code> status to
589 <tr><td>flushpackets</td>
591 <td>Determines whether the proxy module will auto-flush the output
592 brigade after each "chunk" of data. 'off' means that it will flush
593 only when needed, 'on' means after each chunk is sent and
594 'auto' means poll/wait for a period of time and flush if
595 no input has been received for 'flushwait' milliseconds.
596 Currently this is in effect only for AJP.
598 <tr><td>flushwait</td>
600 <td>The time to wait for additional input, in milliseconds, before
601 flushing the output brigade if 'flushpackets' is 'auto'.
603 <tr><td>keepalive</td>
605 <td>This parameter should be used when you have a firewall between your
606 Apache and the backend server, who tend to drop inactive connections.
607 This flag will tell the Operating System to send <code>KEEP_ALIVE</code>
608 messages on inactive connections (interval depends on global OS settings,
609 generally 120ms), and thus prevent the firewall to drop the connection.
610 To enable keepalive set this property value to <code>On</code>.
614 <td>Sets the load balancer cluster set that the worker is a member
615 of. The load balancer will try all members of a lower numbered
616 lbset before trying higher numbered ones.
620 <td>Ping property told webserver to send a <code>CPING</code>
621 request on ajp13 connection before forwarding to it a request.
622 The parameter is the delay in seconds to wait for the
623 <code>CPONG</code> reply.
624 This features has been added to avoid problem with hung and
625 busy Tomcat's and require ajp13 ping/pong support which has
626 been implemented on Tomcat 3.3.2+, 4.1.28+ and 5.0.13+.
627 It will inrease the network traffic during the normal operation
628 which could be an issue for you, but it will lower down the
629 traffic in case some of the cluster nodes are down or buys.
630 Currently this is in effect only for AJP.
632 <tr><td>redirect</td>
634 <td>Redirection Route of the worker. This value is usually
635 set dynamically to enable safe removal of the node from
636 the cluster. If set all requests without session id will be
637 redirected to the BalancerMember that has route parametar
642 <td>Connection pool worker retry timeout in seconds.
643 If the connection pool worker to the backend server is in the error state,
644 Apache will not forward any requests to that server until the timeout
645 expires. This enables to shut down the backend server for maintenance,
646 and bring it back online later.
650 <td>Route of the worker when used inside load balancer.
651 The route is a value appended to seesion id.
655 <td>Single letter value defining the initial status of
656 this worker: 'D' is disabled, 'S' is stopped, 'H' is hot-standby
657 and 'E' is in an error state. Status can be set (which is the default)
658 by prepending with '+' or cleared by prepending with '-'.
659 Thus, a setting of 'S-E' sets this worker to Stopped and
660 clears the in-error flag.
663 <td><directive>Timeout</directive></td>
664 <td>Connection timeout in seconds.
665 If not set the Apache will wait until the free connection
666 is available. This directive is used for limiting the number
667 of connections to the backend server together with <code>max</code>
672 <td>Time To Live for the inactive connections above the
673 <code>smax</code> connections in seconds. Apache will close all
674 connections that has not been used inside that time period.
679 <p>If the Proxy directive scheme starts with the
680 <code>balancer://</code> then a virtual worker that does not really
681 communicate with the backend server will be created. Instead it is responsible
682 for the management of several "real" workers. In that case the special set of
683 parameters can be add to this virtual worker. See <module>mod_proxy_balancer</module>
684 for more information about how the balancer works.
687 <tr><th>Parameter</th>
689 <th>Description</th></tr>
690 <tr><td>lbmethod</td>
692 <td>Balancer load-balance method. Select the load-balancing scheduler
693 method to use. Either <code>byrequests</code>, to perform weighted
694 request counting or <code>bytraffic</code>, to perform weighted
695 traffic byte count balancing. Default is <code>byrequests</code>.
697 <tr><td>maxattempts</td>
699 <td>Maximum number of failover attempts before giving up.
701 <tr><td>nofailover</td>
703 <td>If set to <code>On</code> the session will break if the worker is in
704 error state or disabled. Set this value to On if backend servers do not
705 support session replication.
707 <tr><td>stickysession</td>
709 <td>Balancer sticky session name. The value is usually set to something
710 like <code>JSESSIONID</code> or <code>PHPSESSIONID</code>,
711 and it depends on the backend application server that support sessions.
715 <td>Balancer timeout in seconds. If set this will be the maximum time
716 to wait for a free worker. Default is not to wait.
720 <p>A sample balancer setup</p>
722 ProxyPass /special-area http://special.example.com/ smax=5 max=10<br />
723 ProxyPass / balancer://mycluster/ stickysession=jsessionid nofailover=On<br />
724 <Proxy balancer://mycluster><br />
726 BalancerMember http://1.2.3.4:8009<br />
727 BalancerMember http://1.2.3.5:8009 smax=10<br />
728 # Less powerful server, don't send as many requests there<br />
729 BalancerMember http://1.2.3.6:8009 smax=1 loadfactor=20<br />
734 <p>Setting up a hot-standby, that will only be used if no other
735 members are available</p>
737 ProxyPass / balancer://hotcluster/ <br />
738 <Proxy balancer://hotcluster><br />
740 BalancerMember http://1.2.3.4:8009 loadfactor=1<br />
741 BalancerMember http://1.2.3.5:8009 loadfactor=2<br />
742 # The below is the hot standby<br />
743 BalancerMember http://1.2.3.6:8009 status=+H<br />
744 ProxySet lbmethod=bytraffic
750 <p>When used inside a <directive type="section" module="core"
751 >Location</directive> section, the first argument is omitted and the local
752 directory is obtained from the <directive type="section" module="core"
753 >Location</directive>.</p>
755 <p>If you require a more flexible reverse-proxy configuration, see the
756 <directive module="mod_rewrite">RewriteRule</directive> directive with the
757 <code>[P]</code> flag.</p>
762 <name>ProxyPassMatch</name>
763 <description>Maps remote servers into the local server URL-space using regular expressions</description>
764 <syntax>ProxyPassMatch [<var>regex</var>] !|<var>url</var> [<var>key=value</var>
765 <var>[key=value</var> ...]]</syntax>
766 <contextlist><context>server config</context><context>virtual host</context>
767 <context>directory</context>
771 <p>This directive is equivalent to <directive module="mod_proxy">ProxyPass</directive>,
772 but makes use of regular expressions, instead of simple prefix matching. The
773 supplied regular expression is matched against the <var>url</var>, and if it
774 matches, the server will substitute any parenthesized matches into the given
775 string and use it as a new <var>url</var>.</p>
777 <p>Suppose the local server has address <code>http://example.com/</code>;
781 ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com$1
784 <p>will cause a local request for
785 <code>http://example.com/mirror/foo/bar.gif</code> to be internally converted
786 into a proxy request to <code>http://backend.example.com/foo/bar.gif</code>.</p>
788 <p>The <code>!</code> directive is useful in situations where you don't want
789 to reverse-proxy a subdirectory.</p>
794 <name>ProxyPassReverse</name>
795 <description>Adjusts the URL in HTTP response headers sent from a reverse
796 proxied server</description>
797 <syntax>ProxyPassReverse [<var>path</var>] <var>url</var></syntax>
798 <contextlist><context>server config</context><context>virtual host</context>
799 <context>directory</context>
803 <p>This directive lets Apache adjust the URL in the <code>Location</code>,
804 <code>Content-Location</code> and <code>URI</code> headers on HTTP redirect
805 responses. This is essential when Apache is used as a reverse proxy to avoid
806 by-passing the reverse proxy because of HTTP redirects on the backend
807 servers which stay behind the reverse proxy.</p>
809 <p>Only the HTTP response headers specifically mentioned above
810 will be rewritten. Apache will not rewrite other response
811 headers, nor will it rewrite URL references inside HTML pages.
812 This means that if the proxied content contains absolute URL
813 references, they will by-pass the proxy. A third-party module
814 that will look inside the HTML and rewrite URL references is Nick
815 Kew's <a href="http://apache.webthing.com/mod_proxy_html/"
816 >mod_proxy_html</a>.</p>
818 <p><var>path</var> is the name of a local virtual path. <var>url</var> is a
819 partial URL for the remote server - the same way they are used for the
820 <directive module="mod_proxy">ProxyPass</directive> directive.</p>
822 <p>For example, suppose the local server has address
823 <code>http://example.com/</code>; then</p>
826 ProxyPass /mirror/foo/ http://backend.example.com/<br />
827 ProxyPassReverse /mirror/foo/ http://backend.example.com/<br />
828 ProxyPassReverseCookieDomain backend.example.com public.example.com<br />
829 ProxyPassReverseCookiePath / /mirror/foo/
832 <p>will not only cause a local request for the
833 <code>http://example.com/mirror/foo/bar</code> to be internally converted
834 into a proxy request to <code>http://backend.example.com/bar</code>
835 (the functionality <code>ProxyPass</code> provides here). It also takes care
836 of redirects the server <code>backend.example.com</code> sends: when
837 <code>http://backend.example.com/bar</code> is redirected by him to
838 <code>http://backend.example.com/quux</code> Apache adjusts this to
839 <code>http://example.com/mirror/foo/quux</code> before forwarding the HTTP
840 redirect response to the client. Note that the hostname used for
841 constructing the URL is chosen in respect to the setting of the <directive
842 module="core">UseCanonicalName</directive> directive.</p>
844 <p>Note that this <directive>ProxyPassReverse</directive> directive can
845 also be used in conjunction with the proxy pass-through feature
846 (<code>RewriteRule ... [P]</code>) from <module>mod_rewrite</module>
847 because it doesn't depend on a corresponding <directive module="mod_proxy"
848 >ProxyPass</directive> directive.</p>
850 <p>When used inside a <directive type="section" module="core"
851 >Location</directive> section, the first argument is omitted and the local
852 directory is obtained from the <directive type="section" module="core"
853 >Location</directive>.</p>
858 <name>ProxyPassReverseCookieDomain</name>
859 <description>Adjusts the Domain string in Set-Cookie headers from a reverse-
860 proxied server</description>
861 <syntax>ProxyPassReverseCookieDomain <var>internal-domain</var> <var>public-domain</var></syntax>
862 <contextlist><context>server config</context><context>virtual host</context>
863 <context>directory</context>
866 <p>Usage is basically similar to
867 <directive module="mod_proxy">ProxyPassReverse</directive>, but instead of
868 rewriting headers that are a URL, this rewrites the <code>domain</code>
869 string in <code>Set-Cookie</code> headers.</p>
873 <name>ProxyPassReverseCookiePath</name>
874 <description>Adjusts the Path string in Set-Cookie headers from a reverse-
875 proxied server</description>
876 <syntax>ProxyPassReverseCookiePath <var>internal-path</var> <var>public-path</var></syntax>
877 <contextlist><context>server config</context><context>virtual host</context>
878 <context>directory</context>
881 <p>Usage is basically similar to
882 <directive module="mod_proxy">ProxyPassReverse</directive>, but instead of
883 rewriting headers that are a URL, this rewrites the <code>path</code>
884 string in <code>Set-Cookie</code> headers.</p>
890 <name>AllowCONNECT</name>
891 <description>Ports that are allowed to <code>CONNECT</code> through the
893 <syntax>AllowCONNECT <var>port</var> [<var>port</var>] ...</syntax>
894 <default>AllowCONNECT 443 563</default>
895 <contextlist><context>server config</context><context>virtual host</context>
899 <p>The <directive>AllowCONNECT</directive> directive specifies a list
900 of port numbers to which the proxy <code>CONNECT</code> method may
901 connect. Today's browsers use this method when a <code>https</code>
902 connection is requested and proxy tunneling over HTTP is in effect.</p>
904 <p>By default, only the default https port (<code>443</code>) and the
905 default snews port (<code>563</code>) are enabled. Use the
906 <directive>AllowCONNECT</directive> directive to override this default and
907 allow connections to the listed ports only.</p>
909 <p>Note that you'll need to have <module>mod_proxy_connect</module> present
910 in the server in order to get the support for the <code>CONNECT</code> at
916 <name>ProxyBlock</name>
917 <description>Words, hosts, or domains that are banned from being
918 proxied</description>
919 <syntax>ProxyBlock *|<var>word</var>|<var>host</var>|<var>domain</var>
920 [<var>word</var>|<var>host</var>|<var>domain</var>] ...</syntax>
921 <contextlist><context>server config</context><context>virtual host</context>
925 <p>The <directive>ProxyBlock</directive> directive specifies a list of
926 words, hosts and/or domains, separated by spaces. HTTP, HTTPS, and
927 FTP document requests to sites whose names contain matched words,
928 hosts or domains are <em>blocked</em> by the proxy server. The proxy
929 module will also attempt to determine IP addresses of list items which
930 may be hostnames during startup, and cache them for match test as
931 well. That may slow down the startup time of the server.</p>
933 <example><title>Example</title>
934 ProxyBlock joes-garage.com some-host.co.uk rocky.wotsamattau.edu
937 <p><code>rocky.wotsamattau.edu</code> would also be matched if referenced by
940 <p>Note that <code>wotsamattau</code> would also be sufficient to match
941 <code>wotsamattau.edu</code>.</p>
943 <p>Note also that</p>
949 <p>blocks connections to all sites.</p>
954 <name>ProxyReceiveBufferSize</name>
955 <description>Network buffer size for proxied HTTP and FTP
956 connections</description>
957 <syntax>ProxyReceiveBufferSize <var>bytes</var></syntax>
958 <default>ProxyReceiveBufferSize 0</default>
959 <contextlist><context>server config</context><context>virtual host</context>
963 <p>The <directive>ProxyReceiveBufferSize</directive> directive specifies an
964 explicit (TCP/IP) network buffer size for proxied HTTP and FTP connections,
965 for increased throughput. It has to be greater than <code>512</code> or set
966 to <code>0</code> to indicate that the system's default buffer size should
969 <example><title>Example</title>
970 ProxyReceiveBufferSize 2048
976 <name>ProxyIOBufferSize</name>
977 <description>Determine size of internal data throughput buffer</description>
978 <syntax>ProxyIOBufferSize <var>bytes</var></syntax>
979 <default>ProxyIOBufferSize 8192</default>
980 <contextlist><context>server config</context><context>virtual host</context>
984 <p>The <directive>ProxyIOBufferSize</directive> directive adjusts the size
985 of the internal buffer, which is used as a scratchpad for the data between
986 input and output. The size must be less or equal <code>8192</code>.</p>
988 <p>In almost every case there's no reason to change that value.</p>
993 <name>ProxyMaxForwards</name>
994 <description>Maximium number of proxies that a request can be forwarded
995 through</description>
996 <syntax>ProxyMaxForwards <var>number</var></syntax>
997 <default>ProxyMaxForwards 10</default>
998 <contextlist><context>server config</context><context>virtual host</context>
1000 <compatibility>Available in Apache 2.0 and later</compatibility>
1003 <p>The <directive>ProxyMaxForwards</directive> directive specifies the
1004 maximum number of proxies through which a request may pass, if there's no
1005 <code>Max-Forwards</code> header supplied with the request. This is
1006 set to prevent infinite proxy loops, or a DoS attack.</p>
1008 <example><title>Example</title>
1012 </directivesynopsis>
1015 <name>NoProxy</name>
1016 <description>Hosts, domains, or networks that will be connected to
1017 directly</description>
1018 <syntax>NoProxy <var>host</var> [<var>host</var>] ...</syntax>
1019 <contextlist><context>server config</context><context>virtual host</context>
1023 <p>This directive is only useful for Apache proxy servers within
1024 intranets. The <directive>NoProxy</directive> directive specifies a
1025 list of subnets, IP addresses, hosts and/or domains, separated by
1026 spaces. A request to a host which matches one or more of these is
1027 always served directly, without forwarding to the configured
1028 <directive module="mod_proxy">ProxyRemote</directive> proxy server(s).</p>
1030 <example><title>Example</title>
1031 ProxyRemote * http://firewall.mycompany.com:81<br />
1032 NoProxy .mycompany.com 192.168.112.0/21
1035 <p>The <var>host</var> arguments to the <directive>NoProxy</directive>
1036 directive are one of the following type list:</p>
1039 <!-- ===================== Domain ======================= -->
1040 <dt><var><a name="domain" id="domain">Domain</a></var></dt>
1042 <p>A <dfn>Domain</dfn> is a partially qualified DNS domain name, preceded
1043 by a period. It represents a list of hosts which logically belong to the
1044 same DNS domain or zone (<em>i.e.</em>, the suffixes of the hostnames are
1045 all ending in <var>Domain</var>).</p>
1047 <example><title>Examples</title>
1051 <p>To distinguish <var>Domain</var>s from <var><a href="#hostname"
1052 >Hostname</a></var>s (both syntactically and semantically; a DNS domain can
1053 have a DNS A record, too!), <var>Domain</var>s are always written with a
1056 <note><title>Note</title>
1057 <p>Domain name comparisons are done without regard to the case, and
1058 <var>Domain</var>s are always assumed to be anchored in the root of the
1059 DNS tree, therefore two domains <code>.MyDomain.com</code> and
1060 <code>.mydomain.com.</code> (note the trailing period) are considered
1061 equal. Since a domain comparison does not involve a DNS lookup, it is much
1062 more efficient than subnet comparison.</p>
1065 <!-- ===================== SubNet ======================= -->
1066 <dt><var><a name="subnet" id="subnet">SubNet</a></var></dt>
1068 <p>A <dfn>SubNet</dfn> is a partially qualified internet address in
1069 numeric (dotted quad) form, optionally followed by a slash and the netmask,
1070 specified as the number of significant bits in the <var>SubNet</var>. It is
1071 used to represent a subnet of hosts which can be reached over a common
1072 network interface. In the absence of the explicit net mask it is assumed
1073 that omitted (or zero valued) trailing digits specify the mask. (In this
1074 case, the netmask can only be multiples of 8 bits wide.) Examples:</p>
1077 <dt><code>192.168</code> or <code>192.168.0.0</code></dt>
1078 <dd>the subnet 192.168.0.0 with an implied netmask of 16 valid bits
1079 (sometimes used in the netmask form <code>255.255.0.0</code>)</dd>
1080 <dt><code>192.168.112.0/21</code></dt>
1081 <dd>the subnet <code>192.168.112.0/21</code> with a netmask of 21
1082 valid bits (also used in the form <code>255.255.248.0</code>)</dd>
1085 <p>As a degenerate case, a <em>SubNet</em> with 32 valid bits is the
1086 equivalent to an <var><a href="#ipadr">IPAddr</a></var>, while a <var>SubNet</var> with zero
1087 valid bits (<em>e.g.</em>, 0.0.0.0/0) is the same as the constant
1088 <var>_Default_</var>, matching any IP address.</p></dd>
1090 <!-- ===================== IPAddr ======================= -->
1091 <dt><var><a name="ipaddr" id="ipaddr">IPAddr</a></var></dt>
1093 <p>A <dfn>IPAddr</dfn> represents a fully qualified internet address in
1094 numeric (dotted quad) form. Usually, this address represents a host, but
1095 there need not necessarily be a DNS domain name connected with the
1097 <example><title>Example</title>
1101 <note><title>Note</title>
1102 <p>An <var>IPAddr</var> does not need to be resolved by the DNS system, so
1103 it can result in more effective apache performance.</p>
1106 <!-- ===================== Hostname ======================= -->
1107 <dt><var><a name="hostname" id="hostname">Hostname</a></var></dt>
1109 <p>A <dfn>Hostname</dfn> is a fully qualified DNS domain name which can
1110 be resolved to one or more <var><a href="#ipaddr">IPAddrs</a></var> via the
1111 DNS domain name service. It represents a logical host (in contrast to
1112 <var><a href="#domain">Domain</a></var>s, see above) and must be resolvable
1113 to at least one <var><a href="#ipaddr">IPAddr</a></var> (or often to a list
1114 of hosts with different <var><a href="#ipaddr">IPAddr</a></var>s).</p>
1116 <example><title>Examples</title>
1117 prep.ai.mit.edu<br />
1121 <note><title>Note</title>
1122 <p>In many situations, it is more effective to specify an <var><a
1123 href="#ipaddr">IPAddr</a></var> in place of a <var>Hostname</var> since a
1124 DNS lookup can be avoided. Name resolution in Apache can take a remarkable
1125 deal of time when the connection to the name server uses a slow PPP
1127 <p><var>Hostname</var> comparisons are done without regard to the case,
1128 and <var>Hostname</var>s are always assumed to be anchored in the root
1129 of the DNS tree, therefore two hosts <code>WWW.MyDomain.com</code>
1130 and <code>www.mydomain.com.</code> (note the trailing period) are
1131 considered equal.</p>
1135 <seealso><a href="../dns-caveats.html">DNS Issues</a></seealso>
1136 </directivesynopsis>
1139 <name>ProxyTimeout</name>
1140 <description>Network timeout for proxied requests</description>
1141 <syntax>ProxyTimeout <var>seconds</var></syntax>
1142 <default>ProxyTimeout 300</default>
1143 <contextlist><context>server config</context><context>virtual host</context>
1145 <compatibility>Available in Apache 2.0.31 and later</compatibility>
1148 <p>This directive allows a user to specifiy a timeout on proxy requests.
1149 This is useful when you have a slow/buggy appserver which hangs, and you
1150 would rather just return a timeout and fail gracefully instead of waiting
1151 however long it takes the server to return.</p>
1153 </directivesynopsis>
1156 <name>ProxyDomain</name>
1157 <description>Default domain name for proxied requests</description>
1158 <syntax>ProxyDomain <var>Domain</var></syntax>
1159 <contextlist><context>server config</context><context>virtual host</context>
1163 <p>This directive is only useful for Apache proxy servers within
1164 intranets. The <directive>ProxyDomain</directive> directive specifies
1165 the default domain which the apache proxy server will belong to. If a
1166 request to a host without a domain name is encountered, a redirection
1167 response to the same host with the configured <var>Domain</var> appended
1168 will be generated.</p>
1170 <example><title>Example</title>
1171 ProxyRemote * http://firewall.mycompany.com:81<br />
1172 NoProxy .mycompany.com 192.168.112.0/21<br />
1173 ProxyDomain .mycompany.com
1176 </directivesynopsis>
1179 <name>ProxyVia</name>
1180 <description>Information provided in the <code>Via</code> HTTP response
1181 header for proxied requests</description>
1182 <syntax>ProxyVia On|Off|Full|Block</syntax>
1183 <default>ProxyVia Off</default>
1184 <contextlist><context>server config</context><context>virtual host</context>
1188 <p>This directive controls the use of the <code>Via:</code> HTTP
1189 header by the proxy. Its intended use is to control the flow of
1190 proxy requests along a chain of proxy servers. See <a
1191 href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> (HTTP/1.1), section
1192 14.45 for an explanation of <code>Via:</code> header lines.</p>
1195 <li>If set to <code>Off</code>, which is the default, no special processing
1196 is performed. If a request or reply contains a <code>Via:</code> header,
1197 it is passed through unchanged.</li>
1199 <li>If set to <code>On</code>, each request and reply will get a
1200 <code>Via:</code> header line added for the current host.</li>
1202 <li>If set to <code>Full</code>, each generated <code>Via:</code> header
1203 line will additionally have the Apache server version shown as a
1204 <code>Via:</code> comment field.</li>
1206 <li>If set to <code>Block</code>, every proxy request will have all its
1207 <code>Via:</code> header lines removed. No new <code>Via:</code> header will
1211 </directivesynopsis>
1214 <name>ProxyErrorOverride</name>
1215 <description>Override error pages for proxied content</description>
1216 <syntax>ProxyErrorOverride On|Off</syntax>
1217 <default>ProxyErrorOverride Off</default>
1218 <contextlist><context>server config</context><context>virtual host</context>
1220 <compatibility>Available in version 2.0 and later</compatibility>
1223 <p>This directive is useful for reverse-proxy setups, where you want to
1224 have a common look and feel on the error pages seen by the end user.
1225 This also allows for included files (via
1226 <module>mod_include</module>'s SSI) to get
1227 the error code and act accordingly (default behavior would display
1228 the error page of the proxied server, turning this on shows the SSI
1231 <p>This directive does not affect the processing of informational (1xx),
1232 normal success (2xx), or redirect (3xx) responses.</p>
1234 </directivesynopsis>
1237 <name>ProxyPassInterpolateEnv</name>
1238 <description>Enable Environment Variable interpolation in Reverse Proxy configurations</description>
1239 <syntax>ProxyPassInterpolateEnv On|Off</syntax>
1240 <default>ProxyPassInterpolateEnv Off</default>
1241 <contextlist><context>server config</context>
1242 <context>virtual host</context>
1243 <context>directory</context>
1245 <compatibility>Available in trunk only</compatibility>
1248 <p>This directive enables reverse proxies to be dynamically
1249 configured using environment variables, which may be set by
1250 another module such as <module>mod_rewrite</module>.
1251 It affects the <directive>ProxyPass</directive>,
1252 <directive>ProxyPassReverse</directive>,
1253 <directive>ProxyPassReverseCookieDomain</directive>, and
1254 <directive>ProxyPassReverseCookiePath</directive> directives,
1255 and causes them to substitute the value of an environment
1256 variable <code>varname</code> for the string <code>${varname}</code>
1257 in configuration directives.</p>
1258 <p>Keep this turned off (for server performance) unless you need it!</p>
1260 </directivesynopsis>