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>
481 <p>The <directive>ProxyBadHeader</directive> directive determines the
482 behaviour of <module>mod_proxy</module> if it receives syntactically invalid
483 response header lines (<em>i.e.</em> containing no colon) from the origin
484 server. The following arguments are possible:</p>
487 <dt><code>IsError</code></dt>
488 <dd>Abort the request and end up with a 502 (Bad Gateway) response. This is
489 the default behaviour.</dd>
491 <dt><code>Ignore</code></dt>
492 <dd>Treat bad header lines as if they weren't sent.</dd>
494 <dt><code>StartBody</code></dt>
495 <dd>When receiving the first bad header line, finish reading the headers and
496 treat the remainder as body. This helps to work around buggy backend servers
497 which forget to insert an empty line between the headers and the body.</dd>
502 <directivesynopsis type="section">
503 <name>ProxyMatch</name>
504 <description>Container for directives applied to regular-expression-matched
505 proxied resources</description>
506 <syntax><ProxyMatch <var>regex</var>> ...</ProxyMatch></syntax>
507 <contextlist><context>server config</context><context>virtual host</context>
511 <p>The <directive type="section">ProxyMatch</directive> directive is
512 identical to the <directive module="mod_proxy"
513 type="section">Proxy</directive> directive, except it matches URLs
514 using <glossary ref="regex">regular expressions</glossary>.</p>
516 <seealso><directive type="section" module="mod_proxy">Proxy</directive></seealso>
520 <name>ProxyPreserveHost</name>
521 <description>Use incoming Host HTTP request header for proxy
522 request</description>
523 <syntax>ProxyPreserveHost On|Off</syntax>
524 <default>ProxyPreserveHost Off</default>
525 <contextlist><context>server config</context><context>virtual host</context>
526 <context>directory</context>
528 <compatibility>Usable in directory
529 context in 2.3.3 and later.</compatibility>
532 <p>When enabled, this option will pass the Host: line from the incoming
533 request to the proxied host, instead of the hostname specified in the
534 <directive>ProxyPass</directive> line.</p>
536 <p>This option should normally be turned <code>Off</code>. It is mostly
537 useful in special configurations like proxied mass name-based virtual
538 hosting, where the original Host header needs to be evaluated by the
544 <name>ProxyRequests</name>
545 <description>Enables forward (standard) proxy requests</description>
546 <syntax>ProxyRequests On|Off</syntax>
547 <default>ProxyRequests Off</default>
548 <contextlist><context>server config</context><context>virtual host</context>
552 <p>This allows or prevents Apache httpd from functioning as a forward proxy
553 server. (Setting ProxyRequests to <code>Off</code> does not disable use of
554 the <directive module="mod_proxy">ProxyPass</directive> directive.)</p>
556 <p>In a typical reverse proxy or gateway configuration, this
557 option should be set to
558 <code>Off</code>.</p>
560 <p>In order to get the functionality of proxying HTTP or FTP sites, you
561 need also <module>mod_proxy_http</module> or <module>mod_proxy_ftp</module>
562 (or both) present in the server.</p>
564 <p>In order to get the functionality of (forward) proxying HTTPS sites, you
565 need <module>mod_proxy_connect</module> enabled in the server.</p>
567 <note type="warning"><title>Warning</title>
568 <p>Do not enable proxying with <directive
569 module="mod_proxy">ProxyRequests</directive> until you have <a
570 href="#access">secured your server</a>. Open proxy servers are dangerous
571 both to your network and to the Internet at large.</p>
574 <seealso><a href="#forwardreverse">Forward and Reverse Proxies/Gateways</a></seealso>
578 <name>ProxyRemote</name>
579 <description>Remote proxy used to handle certain requests</description>
580 <syntax>ProxyRemote <var>match</var> <var>remote-server</var></syntax>
581 <contextlist><context>server config</context><context>virtual host</context>
585 <p>This defines remote proxies to this proxy. <var>match</var> is either the
586 name of a URL-scheme that the remote server supports, or a partial URL
587 for which the remote server should be used, or <code>*</code> to indicate
588 the server should be contacted for all requests. <var>remote-server</var> is
589 a partial URL for the remote server. Syntax:</p>
592 <dfn>remote-server</dfn> =
593 <var>scheme</var>://<var>hostname</var>[:<var>port</var>]
596 <p><var>scheme</var> is effectively the protocol that should be used to
597 communicate with the remote server; only <code>http</code> and <code>https</code>
598 are supported by this module. When using <code>https</code>, the requests
599 are forwarded through the remote proxy using the HTTP CONNECT method.</p>
601 <example><title>Example</title>
602 <highlight language="config">
603 ProxyRemote http://goodguys.example.com/ http://mirrorguys.example.com:8000
604 ProxyRemote * http://cleverproxy.localdomain
605 ProxyRemote ftp http://ftpproxy.mydomain:8080
609 <p>In the last example, the proxy will forward FTP requests, encapsulated
610 as yet another HTTP proxy request, to another proxy which can handle
613 <p>This option also supports reverse proxy configuration - a backend
614 webserver can be embedded within a virtualhost URL space even if that
615 server is hidden by another forward proxy.</p>
620 <name>ProxyRemoteMatch</name>
621 <description>Remote proxy used to handle requests matched by regular
622 expressions</description>
623 <syntax>ProxyRemoteMatch <var>regex</var> <var>remote-server</var></syntax>
624 <contextlist><context>server config</context><context>virtual host</context>
628 <p>The <directive>ProxyRemoteMatch</directive> is identical to the
629 <directive module="mod_proxy">ProxyRemote</directive> directive, except the
630 first argument is a <glossary ref="regex">regular expression</glossary>
631 match against the requested URL.</p>
636 <name>BalancerGrowth</name>
637 <description>Number of additional Balancers that can be added Post-configuration</description>
638 <syntax>BalancerGrowth <var>#</var></syntax>
639 <default>BalancerGrowth 5</default>
640 <contextlist><context>server config</context><context>virtual host</context></contextlist>
641 <compatibility>BalancerGrowth is only available in Apache HTTP Server 2.3.13
642 and later.</compatibility>
644 <p>This directive allows for growth potential in the number of
645 Balancers available for a virtualhost in addition to the
646 number pre-configured. It only takes effect if there is at
647 least 1 pre-configured Balancer.</p>
652 <name>BalancerPersist</name>
653 <description>Attempt to persist changes made by the Balancer Manager across restarts.</description>
654 <syntax>BalancerPersist On|Off</syntax>
655 <default>BalancerPersist Off</default>
656 <contextlist><context>server config</context><context>virtual host</context></contextlist>
657 <compatibility>BalancerPersist is only available in Apache HTTP Server 2.5.0
658 and later.</compatibility>
660 <p>This directive will cause the shared memory storage associated
661 with the balancers and balancer members to be persisted across
662 restarts. This allows these local changes to not be lost during the
663 normal restart/graceful state transitions.</p>
668 <name>ProxyPassInherit</name>
669 <description>Inherit ProxyPass directives defined from the main server</description>
670 <syntax>ProxyPassInherit On|Off</syntax>
671 <default>ProxyPassInherit On</default>
672 <contextlist><context>server config</context><context>virtual host</context></contextlist>
673 <compatibility>ProxyPassInherit is only available in Apache HTTP Server 2.5.0 and later.
674 and later.</compatibility>
676 <p>This directive will cause the current server/vhost to "inherit"
677 <directive module="mod_proxy">ProxyPass</directive>
678 directives defined in the main server. This can cause issues and
679 inconsistent behavior if using the Balancer Manager for dynamic changes
680 and so should be disabled if using that feature.</p>
681 <p>The setting in the global server defines the default for all vhosts.</p>
682 <p>Disabling ProxyPassInherit also disables <directive module="mod_proxy">BalancerInherit</directive>.</p>
687 <name>BalancerInherit</name>
688 <description>Inherit proxy Balancers/Workers defined from the main server</description>
689 <syntax>BalancerInherit On|Off</syntax>
690 <default>BalancerInherit On</default>
691 <contextlist><context>server config</context><context>virtual host</context></contextlist>
692 <compatibility>BalancerInherit is only available in Apache HTTP Server 2.4.4 and later.
693 and later.</compatibility>
695 <p>This directive will cause the current server/vhost to "inherit"
696 Balancers and Workers defined in the main server. This can cause issues and
697 inconsistent behavior if using the Balancer Manager for dynamic changes
698 and so should be disabled if using that feature.</p>
699 <p>The setting in the global server defines the default for all vhosts.</p>
700 <p>Disabling <directive module="mod_proxy">ProxyPassInherit</directive> also disables BalancerInherit.</p>
705 <name>BalancerMember</name>
706 <description>Add a member to a load balancing group</description>
707 <syntax>BalancerMember [<var>balancerurl</var>] <var>url</var> [<var
708 >key=value [key=value ...]]</var></syntax>
709 <contextlist><context>directory</context>
712 <p>This directive adds a member to a load balancing group. It could be used
713 within a <code><Proxy <var>balancer://</var>...></code> container
714 directive, and can take any of the key value pair parameters available to
715 <directive module="mod_proxy">ProxyPass</directive> directives.</p>
716 <p>One additional parameter is available only to <directive
717 module="mod_proxy">BalancerMember</directive> directives:
718 <var>loadfactor</var>. This is the member load factor - a number between 1
719 (default) and 100, which defines the weighted load to be applied to the
720 member in question.</p>
721 <p>The balancerurl is only needed when not in <code><Proxy <var>balancer://</var>...></code>
722 container directive. It corresponds to the url of a balancer defined in
723 <directive module="mod_proxy">ProxyPass</directive> directive.</p>
724 <p>The path component of the balancer URL in any
725 <code><Proxy <var>balancer://</var>...></code> container directive
727 <p>Trailing slashes should typically be removed from the URL of a
728 <code>BalancerMember</code>.</p>
733 <name>ProxySet</name>
734 <description>Set various Proxy balancer or member parameters</description>
735 <syntax>ProxySet <var>url</var> <var>key=value [key=value ...]</var></syntax>
736 <contextlist><context>directory</context>
739 <p>This directive is used as an alternate method of setting any of the
740 parameters available to Proxy balancers and workers normally done via the
741 <directive module="mod_proxy">ProxyPass</directive> directive. If used
742 within a <code><Proxy <var>balancer url|worker url</var>></code>
743 container directive, the <var>url</var> argument is not required. As a side
744 effect the respective balancer or worker gets created. This can be useful
745 when doing reverse proxying via a
746 <directive module="mod_rewrite">RewriteRule</directive> instead of a
747 <directive module="mod_proxy">ProxyPass</directive> directive.</p>
750 <highlight language="config">
751 <Proxy balancer://hotcluster>
752 BalancerMember http://www2.example.com:8080 loadfactor=1
753 BalancerMember http://www3.example.com:8080 loadfactor=2
754 ProxySet lbmethod=bytraffic
759 <highlight language="config">
760 <Proxy http://backend>
761 ProxySet keepalive=On
765 <highlight language="config">
766 ProxySet balancer://foo lbmethod=bytraffic timeout=15
769 <highlight language="config">
770 ProxySet ajp://backend:7001 timeout=15
773 <note type="warning"><title>Warning</title>
774 <p>Keep in mind that the same parameter key can have a different meaning
775 depending whether it is applied to a balancer or a worker as shown by the two
776 examples above regarding timeout.</p>
783 <name>ProxyPass</name>
784 <description>Maps remote servers into the local server URL-space</description>
785 <syntax>ProxyPass [<var>path</var>] !|<var>url</var> [<var>key=value</var>
786 <var>[key=value</var> ...]] [nocanon] [interpolate] [noquery]</syntax>
787 <contextlist><context>server config</context><context>virtual host</context>
788 <context>directory</context>
792 <p>This directive allows remote servers to be mapped into the
793 space of the local server; the local server does not act as a
794 proxy in the conventional sense, but appears to be a mirror of the
795 remote server. The local server is often called a <dfn>reverse
796 proxy</dfn> or <dfn>gateway</dfn>. The <var>path</var> is the name of
797 a local virtual path; <var>url</var> is a partial URL for the
798 remote server and cannot include a query string.</p>
800 <note type="warning">The <directive
801 module="mod_proxy">ProxyRequests</directive> directive should
802 usually be set <strong>off</strong> when using
803 <directive>ProxyPass</directive>.</note>
805 <p>Suppose the local server has address <code>http://example.com/</code>;
808 <highlight language="config">
809 <Location /mirror/foo/>
810 ProxyPass http://backend.example.com/
814 <p>will cause a local request for
815 <code>http://example.com/mirror/foo/bar</code> to be internally converted
816 into a proxy request to <code>http://backend.example.com/bar</code>.</p>
818 <p>The following alternative syntax is possible, however it can carry a
819 performance penalty when present in very large numbers. The advantage of
820 the below syntax is that it allows for dynamic control via the
821 <a href="mod_proxy_balancer.html#balancer_manager">Balancer Manager</a> interface:</p>
823 <highlight language="config">
824 ProxyPass /mirror/foo/ http://backend.example.com/
827 <note type="warning">
828 <p>If the first argument ends with a trailing <strong>/</strong>, the second
829 argument should also end with a trailing <strong>/</strong> and vice
830 versa. Otherwise the resulting requests to the backend may miss some
831 needed slashes and do not deliver the expected results.
835 <p>The <code>!</code> directive is useful in situations where you don't want
836 to reverse-proxy a subdirectory, <em>e.g.</em></p>
838 <highlight language="config">
839 <Location /mirror/foo/>
840 ProxyPass http://backend.example.com/
842 <Location /mirror/foo/i>
847 <highlight language="config">
848 ProxyPass /mirror/foo/i !
849 ProxyPass /mirror/foo http://backend.example.com
852 <p>will proxy all requests to <code>/mirror/foo</code> to
853 <code>backend.example.com</code> <em>except</em> requests made to
854 <code>/mirror/foo/i</code>.</p>
856 <note type="warning"><title>Ordering ProxyPass Directives</title>
857 <p>The configured <directive module="mod_proxy">ProxyPass</directive>
858 and <directive module="mod_proxy">ProxyPassMatch</directive>
859 rules are checked in the order of configuration. The first rule that
860 matches wins. So usually you should sort conflicting
861 <directive module="mod_proxy">ProxyPass</directive> rules starting with the
862 longest URLs first. Otherwise later rules for longer URLS will be hidden
863 by any earlier rule which uses a leading substring of the URL. Note that
864 there is some relation with worker sharing. In contrast, only one
865 <directive module="mod_proxy">ProxyPass</directive> directive can be placed
866 in a <directive module="core">Location</directive> block, and the most
867 specific location will take precedence.</p>
869 <p>For the same reasons exclusions must come <em>before</em> the
870 general <directive>ProxyPass</directive> directives.</p>
872 </note> <!-- /ordering_proxypass -->
874 <p>In Apache HTTP Server 2.1 and later, mod_proxy supports pooled
875 connections to a backend server. Connections created on demand
876 can be retained in a pool for future use. Limits on the pool size
877 and other settings can be coded on
878 the <directive>ProxyPass</directive> directive
879 using <code>key=value</code> parameters, described in the table
882 <p>By default, mod_proxy will allow and retain the maximum number of
883 connections that could be used simultaneously by that web server child
884 process. Use the <code>max</code> parameter to reduce the number from
885 the default. Use the <code>ttl</code> parameter to set an optional
886 time to live; connections which have been unused for at least
887 <code>ttl</code> seconds will be closed. <code>ttl</code> can be used
888 to avoid using a connection which is subject to closing because of the
889 backend server's keep-alive timeout.</p>
891 <p>The pool of connections is maintained per web server child
892 process, and <code>max</code> and other settings are not coordinated
893 among all child processes, except when only one child process is allowed
894 by configuration or MPM design.</p>
896 <example><title>Example</title>
897 <highlight language="config">
898 ProxyPass /example http://backend.example.com max=20 ttl=120 retry=300
902 <table border="2"><tr><th>BalancerMember parameters</th></tr></table>
904 <tr><th>Parameter</th>
906 <th>Description</th></tr>
909 <td>Minimum number of connection pool entries, unrelated to the
910 actual number of connections. This only needs to be modified from the
911 default for special circumstances where heap memory associated with the
912 backend connections should be preallocated or retained.</td></tr>
915 <td>Maximum number of connections that will be allowed to the
916 backend server. The default for this limit is the number of threads
917 per process in the active MPM. In the Prefork MPM, this is always 1,
918 while with other MPMs it is controlled by the
919 <directive>ThreadsPerChild</directive> directive.</td></tr>
922 <td>Retained connection pool entries above this limit are freed
923 during certain operations if they have been unused for longer than
924 the time to live, controlled by the <code>ttl</code> parameter. If
925 the connection pool entry has an associated connection, it will be
926 closed. This only needs to be modified from the default for special
927 circumstances where connection pool entries and any associated
928 connections which have exceeded the time to live need to be freed or
929 closed more aggressively.</td></tr>
932 <td>If set this will be the maximum time to wait for a free
933 connection in the connection pool, in milliseconds. If there are no free
934 connections in the pool the Apache httpd will return <code>SERVER_BUSY</code>
935 status to the client.
937 <tr><td>connectiontimeout</td>
939 <td>Connect timeout in seconds.
940 The number of seconds Apache httpd waits for the creation of a connection to
941 the backend to complete. By adding a postfix of ms the timeout can be
942 also set in milliseconds.
944 <tr><td>disablereuse</td>
946 <td>This parameter should be used when you want to force mod_proxy
947 to immediately close a connection to the backend after being used, and
948 thus, disable its persistent connection and pool for that backend.
949 This helps in various situations where a firewall between Apache
951 the backend server (regardless of protocol) tends to silently
952 drop connections or when backends themselves may be under round-
953 robin DNS. To disable connection pooling reuse,
954 set this property value to <code>On</code>.
956 <tr><td>flushpackets</td>
958 <td>Determines whether the proxy module will auto-flush the output
959 brigade after each "chunk" of data. 'off' means that it will flush
960 only when needed, 'on' means after each chunk is sent and
961 'auto' means poll/wait for a period of time and flush if
962 no input has been received for 'flushwait' milliseconds.
963 Currently this is in effect only for AJP.
965 <tr><td>flushwait</td>
967 <td>The time to wait for additional input, in milliseconds, before
968 flushing the output brigade if 'flushpackets' is 'auto'.
970 <tr><td>iobuffersize</td>
972 <td>Adjusts the size of the internal scratchpad IO buffer. This allows you
973 to override the <directive>ProxyIOBufferSize</directive> for a specific worker.
974 This must be at least 512 or set to 0 for the system default of 8192.
976 <tr><td>keepalive</td>
978 <td><p>This parameter should be used when you have a firewall between your
979 Apache httpd and the backend server, who tend to drop inactive connections.
980 This flag will tell the Operating System to send <code>KEEP_ALIVE</code>
981 messages on inactive connections and thus prevent the firewall to drop the connection.
982 To enable keepalive set this property value to <code>On</code>. </p>
983 <p>The frequency of initial and subsequent TCP keepalive probes
984 depends on global OS settings, and may be as high as 2 hours. To be useful,
985 the frequency configured in the OS must be smaller than the threshold used
990 <td>Sets the load balancer cluster set that the worker is a member
991 of. The load balancer will try all members of a lower numbered
992 lbset before trying higher numbered ones.
996 <td>Ping property tells the webserver to "test" the connection to
997 the backend before forwarding the request. For AJP, it causes
998 <module>mod_proxy_ajp</module>to send a <code>CPING</code>
999 request on the ajp13 connection (implemented on Tomcat 3.3.2+, 4.1.28+
1000 and 5.0.13+). For HTTP, it causes <module>mod_proxy_http</module>
1001 to send a <code>100-Continue</code> to the backend (only valid for
1002 HTTP/1.1 - for non HTTP/1.1 backends, this property has no
1003 effect). In both cases the parameter is the delay in seconds to wait
1005 This feature has been added to avoid problems with hung and
1007 This will increase the network traffic during the normal operation
1008 which could be an issue, but it will lower the
1009 traffic in case some of the cluster nodes are down or busy.
1010 By adding a postfix of ms the delay can be also set in
1013 <tr><td>receivebuffersize</td>
1015 <td>Adjusts the size of the explicit (TCP/IP) network buffer size for
1016 proxied connections. This allows you to override the
1017 <directive>ProxyReceiveBufferSize</directive> for a specific worker.
1018 This must be at least 512 or set to 0 for the system default.
1020 <tr><td>redirect</td>
1022 <td>Redirection Route of the worker. This value is usually
1023 set dynamically to enable safe removal of the node from
1024 the cluster. If set all requests without session id will be
1025 redirected to the BalancerMember that has route parameter
1026 equal as this value.
1030 <td>Connection pool worker retry timeout in seconds.
1031 If the connection pool worker to the backend server is in the error state,
1032 Apache httpd will not forward any requests to that server until the timeout
1033 expires. This enables to shut down the backend server for maintenance,
1034 and bring it back online later. A value of 0 means always retry workers
1035 in an error state with no timeout.
1039 <td>Route of the worker when used inside load balancer.
1040 The route is a value appended to session id.
1044 <td>Single letter value defining the initial status of
1047 <tr><td>D: Worker is disabled and will not accept any requests.</td></tr>
1048 <tr><td>S: Worker is administratively stopped.</td></tr>
1049 <tr><td>I: Worker is in ignore-errors mode, and will always be considered available.</td></tr>
1050 <tr><td>H: Worker is in hot-standby mode and will only be used if no other
1051 viable workers are available.</td></tr>
1052 <tr><td>E: Worker is in an error state.</td></tr>
1053 <tr><td>N: Worker is in drain mode, and will only accept existing sticky sessions
1054 destined for itself and ignore all other requests.</td></tr>
1056 can be set (which is the default) by prepending with '+' or
1057 cleared by prepending with '-'.
1058 Thus, a setting of 'S-E' sets this worker to Stopped and
1059 clears the in-error flag.
1061 <tr><td>timeout</td>
1062 <td><directive module="mod_proxy">ProxyTimeout</directive></td>
1063 <td>Connection timeout in seconds.
1064 The number of seconds Apache httpd waits for data sent by / to the backend.
1068 <td>Time to live for inactive connections and associated connection
1069 pool entries, in seconds. Once reaching this limit, a
1070 connection will not be used again; it will be closed at some
1076 <p>If the Proxy directive scheme starts with the
1077 <code>balancer://</code> (eg: <code>balancer://cluster</code>,
1078 any path information is ignored) then a virtual worker that does not really
1079 communicate with the backend server will be created. Instead it is responsible
1080 for the management of several "real" workers. In that case the special set of
1081 parameters can be add to this virtual worker. See <module>mod_proxy_balancer</module>
1082 for more information about how the balancer works.
1084 <table border="2"><tr><th>Balancer parameters</th></tr></table>
1086 <tr><th>Parameter</th>
1088 <th>Description</th></tr>
1089 <tr><td>lbmethod</td>
1091 <td>Balancer load-balance method. Select the load-balancing scheduler
1092 method to use. Either <code>byrequests</code>, to perform weighted
1093 request counting, <code>bytraffic</code>, to perform weighted
1094 traffic byte count balancing, or <code>bybusyness</code>, to perform
1095 pending request balancing. Default is <code>byrequests</code>.
1097 <tr><td>maxattempts</td>
1098 <td>One less than the number of workers, or 1 with a single worker.</td>
1099 <td>Maximum number of failover attempts before giving up.
1101 <tr><td>nofailover</td>
1103 <td>If set to <code>On</code> the session will break if the worker is in
1104 error state or disabled. Set this value to On if backend servers do not
1105 support session replication.
1107 <tr><td>stickysession</td>
1109 <td>Balancer sticky session name. The value is usually set to something
1110 like <code>JSESSIONID</code> or <code>PHPSESSIONID</code>,
1111 and it depends on the backend application server that support sessions.
1112 If the backend application server uses different name for cookies
1113 and url encoded id (like servlet containers) use | to to separate them.
1114 The first part is for the cookie the second for the path.
1116 <tr><td>stickysessionsep</td>
1118 <td>Sets the separation symbol in the session cookie. Some backend application servers
1119 do not use the '.' as the symbol. For example the Oracle Weblogic server uses
1120 '!'. The correct symbol can be set using this option. The setting of 'Off'
1121 signifies that no symbol is used.
1123 <tr><td>scolonpathdelim</td>
1125 <td>If set to <code>On</code> the semi-colon character ';' will be
1126 used as an additional sticky session path deliminator/separator. This
1127 is mainly used to emulate mod_jk's behavior when dealing with paths such
1128 as <code>JSESSIONID=6736bcf34;foo=aabfa</code>
1130 <tr><td>timeout</td>
1132 <td>Balancer timeout in seconds. If set this will be the maximum time
1133 to wait for a free worker. Default is not to wait.
1135 <tr><td>failonstatus</td>
1137 <td>A single or comma-separated list of HTTP status codes. If set this will
1138 force the worker into error state when the backend returns any status code
1139 in the list. Worker recovery behaves the same as other worker errors.
1142 <td><auto></td>
1143 <td>The protective nonce used in the <code>balancer-manager</code> application page.
1144 The default is to use an automatically determined UUID-based
1145 nonce, to provide for further protection for the page. If set,
1146 then the nonce is set to that value. A setting of <code>None</code>
1147 disables all nonce checking.
1148 <note><title>Note</title>
1149 <p>In addition to the nonce, the <code>balancer-manager</code> page
1150 should be protected via an ACL.</p>
1155 <td>Number of additional BalancerMembers to allow to be added
1156 to this balancer in addition to those defined at configuration.
1158 <tr><td>forcerecovery</td>
1160 <td>Force the immediate recovery of all workers without considering the
1161 retry parameter of the workers if all workers of a balancer are
1162 in error state. There might be cases where an already overloaded backend
1163 can get into deeper trouble if the recovery of all workers is enforced
1164 without considering the retry parameter of each worker. In this case
1165 set to <code>Off</code>.
1169 <p>A sample balancer setup</p>
1170 <highlight language="config">
1171 ProxyPass /special-area http://special.example.com smax=5 max=10
1172 ProxyPass / balancer://mycluster/ stickysession=JSESSIONID|jsessionid nofailover=On
1173 <Proxy balancer://mycluster>
1174 BalancerMember ajp://1.2.3.4:8009
1175 BalancerMember ajp://1.2.3.5:8009 loadfactor=20
1176 # Less powerful server, don't send as many requests there,
1177 BalancerMember ajp://1.2.3.6:8009 loadfactor=5
1181 <p>Setting up a hot-standby, that will only be used if no other
1182 members are available</p>
1183 <highlight language="config">
1184 ProxyPass / balancer://hotcluster/
1185 <Proxy balancer://hotcluster>
1186 BalancerMember ajp://1.2.3.4:8009 loadfactor=1
1187 BalancerMember ajp://1.2.3.5:8009 loadfactor=2
1188 # The server below is on hot standby
1189 BalancerMember ajp://1.2.3.6:8009 status=+H
1190 ProxySet lbmethod=bytraffic
1194 <p>Normally, mod_proxy will canonicalise ProxyPassed URLs.
1195 But this may be incompatible with some backends, particularly those
1196 that make use of <var>PATH_INFO</var>. The optional <var>nocanon</var>
1197 keyword suppresses this, and passes the URL path "raw" to the
1198 backend. Note that may affect the security of your backend, as it
1199 removes the normal limited protection against URL-based attacks
1200 provided by the proxy.</p>
1202 <p>The optional <var>interpolate</var> keyword (available in
1203 httpd 2.2.9 and later), in combination with
1204 <directive>ProxyPassInterpolateEnv</directive> causes the ProxyPass
1205 to interpolate environment variables, using the syntax
1206 <var>${VARNAME}</var>. Note that many of the standard CGI-derived
1207 environment variables will not exist when this interpolation happens,
1208 so you may still have to resort to <module>mod_rewrite</module>
1209 for complex rules.</p>
1211 <p>Normally, mod_proxy will include the query string when
1212 generating the <var>SCRIPT_FILENAME</var> environment variable.
1213 The optional <var>noquery</var> keyword (available in
1214 httpd 2.4.1 and later) prevents this.</p>
1216 <p>When used inside a <directive type="section" module="core"
1217 >Location</directive> section, the first argument is omitted and the local
1218 directory is obtained from the <directive type="section" module="core"
1219 >Location</directive>. The same will occur inside a
1220 <directive type="section" module="core">LocationMatch</directive> section,
1221 however ProxyPass does not interpret the regexp as such, so it is necessary
1222 to use <directive>ProxyPassMatch</directive> in this situation instead.</p>
1224 <p>This directive is not supported in <directive type="section" module="core"
1225 >Directory</directive> or <directive type="section" module="core"
1226 >Files</directive> sections.</p>
1228 <p>If you require a more flexible reverse-proxy configuration, see the
1229 <directive module="mod_rewrite">RewriteRule</directive> directive with the
1230 <code>[P]</code> flag.</p>
1233 </directivesynopsis>
1236 <name>ProxyPassMatch</name>
1237 <description>Maps remote servers into the local server URL-space using regular expressions</description>
1238 <syntax>ProxyPassMatch [<var>regex</var>] !|<var>url</var> [<var>key=value</var>
1239 <var>[key=value</var> ...]]</syntax>
1240 <contextlist><context>server config</context><context>virtual host</context>
1241 <context>directory</context>
1245 <p>This directive is equivalent to <directive module="mod_proxy">ProxyPass</directive>,
1246 but makes use of regular expressions, instead of simple prefix matching. The
1247 supplied regular expression is matched against the <var>url</var>, and if it
1248 matches, the server will substitute any parenthesized matches into the given
1249 string and use it as a new <var>url</var>.</p>
1251 <p>Suppose the local server has address <code>http://example.com/</code>;
1254 <highlight language="config">
1255 ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com$1
1258 <p>will cause a local request for
1259 <code>http://example.com/foo/bar.gif</code> to be internally converted
1260 into a proxy request to <code>http://backend.example.com/foo/bar.gif</code>.</p>
1261 <note><title>Note</title>
1262 <p>The URL argument must be parsable as a URL <em>before</em> regexp
1263 substitutions (as well as after). This limits the matches you can use.
1264 For instance, if we had used</p>
1265 <highlight language="config">
1266 ProxyPassMatch ^(/.*\.gif)$ http://backend.example.com:8000$1
1268 <p>in our previous example, it would fail with a syntax error
1269 at server startup. This is a bug (PR 46665 in the ASF bugzilla),
1270 and the workaround is to reformulate the match:</p>
1271 <highlight language="config">
1272 ProxyPassMatch ^/(.*\.gif)$ http://backend.example.com:8000/$1
1275 <p>The <code>!</code> directive is useful in situations where you don't want
1276 to reverse-proxy a subdirectory.</p>
1278 <p>When used inside a <directive type="section" module="core"
1279 >LocationMatch</directive> section, the first argument is omitted and the
1280 regexp is obtained from the <directive type="section" module="core"
1281 >LocationMatch</directive>.</p>
1283 <p>If you require a more flexible reverse-proxy configuration, see the
1284 <directive module="mod_rewrite">RewriteRule</directive> directive with the
1285 <code>[P]</code> flag.</p>
1287 <note type="warning">
1288 <title>Security Warning</title>
1289 <p>Take care when constructing the target URL of the rule, considering
1290 the security impact from allowing the client influence over the set of
1291 URLs to which your server will act as a proxy. Ensure that the scheme
1292 and hostname part of the URL is either fixed, or does not allow the
1293 client undue influence.</p>
1296 </directivesynopsis>
1299 <name>ProxyPassReverse</name>
1300 <description>Adjusts the URL in HTTP response headers sent from a reverse
1301 proxied server</description>
1302 <syntax>ProxyPassReverse [<var>path</var>] <var>url</var>
1303 [<var>interpolate</var>]</syntax>
1304 <contextlist><context>server config</context><context>virtual host</context>
1305 <context>directory</context>
1309 <p>This directive lets Apache httpd adjust the URL in the <code>Location</code>,
1310 <code>Content-Location</code> and <code>URI</code> headers on HTTP
1311 redirect responses. This is essential when Apache httpd is used as a
1312 reverse proxy (or gateway) to avoid by-passing the reverse proxy
1313 because of HTTP redirects on the backend servers which stay behind
1314 the reverse proxy.</p>
1316 <p>Only the HTTP response headers specifically mentioned above
1317 will be rewritten. Apache httpd will not rewrite other response
1318 headers, nor will it by default rewrite URL references inside HTML pages.
1319 This means that if the proxied content contains absolute URL
1320 references, they will by-pass the proxy. To rewrite HTML content to
1321 match the proxy, you must load and enable <module>mod_proxy_html</module>.
1324 <p><var>path</var> is the name of a local virtual path. <var>url</var> is a
1325 partial URL for the remote server - the same way they are used for the
1326 <directive module="mod_proxy">ProxyPass</directive> directive.</p>
1328 <p>For example, suppose the local server has address
1329 <code>http://example.com/</code>; then</p>
1331 <highlight language="config">
1332 ProxyPass /mirror/foo/ http://backend.example.com/
1333 ProxyPassReverse /mirror/foo/ http://backend.example.com/
1334 ProxyPassReverseCookieDomain backend.example.com public.example.com
1335 ProxyPassReverseCookiePath / /mirror/foo/
1338 <p>will not only cause a local request for the
1339 <code>http://example.com/mirror/foo/bar</code> to be internally converted
1340 into a proxy request to <code>http://backend.example.com/bar</code>
1341 (the functionality <code>ProxyPass</code> provides here). It also takes care
1342 of redirects the server <code>backend.example.com</code> sends: when
1343 <code>http://backend.example.com/bar</code> is redirected by him to
1344 <code>http://backend.example.com/quux</code> Apache httpd adjusts this to
1345 <code>http://example.com/mirror/foo/quux</code> before forwarding the HTTP
1346 redirect response to the client. Note that the hostname used for
1347 constructing the URL is chosen in respect to the setting of the <directive
1348 module="core">UseCanonicalName</directive> directive.</p>
1350 <p>Note that this <directive>ProxyPassReverse</directive> directive can
1351 also be used in conjunction with the proxy pass-through feature
1352 (<code>RewriteRule ... [P]</code>) from <module>mod_rewrite</module>
1353 because it doesn't depend on a corresponding <directive module="mod_proxy"
1354 >ProxyPass</directive> directive.</p>
1356 <p>The optional <var>interpolate</var> keyword (available in
1357 httpd 2.2.9 and later), used together with
1358 <directive>ProxyPassInterpolateEnv</directive>, enables interpolation
1359 of environment variables specified using the format <var>${VARNAME}</var>.
1362 <p>When used inside a <directive type="section" module="core"
1363 >Location</directive> section, the first argument is omitted and the local
1364 directory is obtained from the <directive type="section" module="core"
1365 >Location</directive>. The same occurs inside a <directive type="section"
1366 module="core">LocationMatch</directive> section, but will probably not work as
1367 intended, as ProxyPassReverse will interpret the regexp literally as a
1368 path; if needed in this situation, specify the ProxyPassReverse outside
1369 the section, or in a separate <directive type="section" module="core"
1370 >Location</directive> section.</p>
1372 <p>This directive is not supported in <directive type="section" module="core"
1373 >Directory</directive> or <directive type="section" module="core"
1374 >Files</directive> sections.</p>
1376 </directivesynopsis>
1379 <name>ProxyPassReverseCookieDomain</name>
1380 <description>Adjusts the Domain string in Set-Cookie headers from a reverse-
1381 proxied server</description>
1382 <syntax>ProxyPassReverseCookieDomain <var>internal-domain</var>
1383 <var>public-domain</var> [<var>interpolate</var>]</syntax>
1384 <contextlist><context>server config</context><context>virtual host</context>
1385 <context>directory</context>
1388 <p>Usage is basically similar to
1389 <directive module="mod_proxy">ProxyPassReverse</directive>, but instead of
1390 rewriting headers that are a URL, this rewrites the <code>domain</code>
1391 string in <code>Set-Cookie</code> headers.</p>
1393 </directivesynopsis>
1397 <name>ProxyPassReverseCookiePath</name>
1398 <description>Adjusts the Path string in Set-Cookie headers from a reverse-
1399 proxied server</description>
1400 <syntax>ProxyPassReverseCookiePath <var>internal-path</var>
1401 <var>public-path</var> [<var>interpolate</var>]</syntax>
1402 <contextlist><context>server config</context><context>virtual host</context>
1403 <context>directory</context>
1407 Useful in conjunction with
1408 <directive module="mod_proxy">ProxyPassReverse</directive>
1409 in situations where backend URL paths are mapped to public paths on the
1410 reverse proxy. This directive rewrites the <code>path</code> string in
1411 <code>Set-Cookie</code> headers. If the beginning of the cookie path matches
1412 <var>internal-path</var>, the cookie path will be replaced with
1413 <var>public-path</var>.
1415 In the example given with
1416 <directive module="mod_proxy">ProxyPassReverse</directive>, the directive:
1418 <highlight language="config">
1419 ProxyPassReverseCookiePath / /mirror/foo/
1422 will rewrite a cookie with backend path <code>/</code> (or
1423 <code>/example</code> or, in fact, anything) to <code>/mirror/foo/</code>.
1426 </directivesynopsis>
1429 <name>ProxyBlock</name>
1430 <description>Disallow proxy requests to certain hosts</description>
1431 <syntax>ProxyBlock *|<var>hostname</var>|<var>partial-hostname</var> [<var>hostname</var>|<var>partial-hostname</var>]...</syntax>
1432 <contextlist><context>server config</context><context>virtual host</context>
1436 <p>The <directive>ProxyBlock</directive> directive can be used to
1437 block FTP or HTTP access to certain hosts via the proxy, based on
1438 a full or partial hostname match, or, if applicable, an IP address
1441 <p>Each of the arguments to the <directive>ProxyBlock</directive>
1442 directive can be either <code>*</code> or a alphanumeric string.
1443 At startup, the module will attempt to resolve every alphanumeric
1444 string from a DNS name to a set of IP addresses, but any DNS errors
1447 <p>If an asterisk "<code>*</code>" argument is specified,
1448 <module>mod_proxy</module> will deny access to all FTP or HTTP
1451 <p>Otherwise, for any request for an HTTP or FTP resource via the
1452 proxy, <module>mod_proxy</module> will check the hostname of the
1453 request URI against each specified string. If a partial string
1454 match is found, access is denied. If no matches against hostnames
1455 are found, and a remote (forward) proxy is configured using
1456 <directive>ProxyRemote</directive> or
1457 <directive>ProxyRemoteMatch</directive>, access is allowed. If no
1458 remote (forward) proxy is configured, the IP address of the
1459 hostname from the URI is compared against all resolved IP
1460 addresses determined at startup. Access is denied if any match is
1463 <p>Note that the DNS lookups may slow down the startup time of the
1466 <example><title>Example</title>
1467 <highlight language="config">
1468 ProxyBlock news.example.com auctions.example.com friends.example.com
1472 <p>Note that <code>example</code> would also be sufficient to match any
1475 <p>Hosts would also be matched if referenced by IP address.</p>
1477 <p>Note also that</p>
1479 <highlight language="config">
1483 <p>blocks connections to all sites.</p>
1485 </directivesynopsis>
1488 <name>ProxyReceiveBufferSize</name>
1489 <description>Network buffer size for proxied HTTP and FTP
1490 connections</description>
1491 <syntax>ProxyReceiveBufferSize <var>bytes</var></syntax>
1492 <default>ProxyReceiveBufferSize 0</default>
1493 <contextlist><context>server config</context><context>virtual host</context>
1497 <p>The <directive>ProxyReceiveBufferSize</directive> directive specifies an
1498 explicit (TCP/IP) network buffer size for proxied HTTP and FTP connections,
1499 for increased throughput. It has to be greater than <code>512</code> or set
1500 to <code>0</code> to indicate that the system's default buffer size should
1503 <example><title>Example</title>
1504 <highlight language="config">
1505 ProxyReceiveBufferSize 2048
1509 </directivesynopsis>
1512 <name>ProxyIOBufferSize</name>
1513 <description>Determine size of internal data throughput buffer</description>
1514 <syntax>ProxyIOBufferSize <var>bytes</var></syntax>
1515 <default>ProxyIOBufferSize 8192</default>
1516 <contextlist><context>server config</context><context>virtual host</context>
1520 <p>The <directive>ProxyIOBufferSize</directive> directive adjusts the size
1521 of the internal buffer, which is used as a scratchpad for the data between
1522 input and output. The size must be at least <code>512</code>.</p>
1524 <p>In almost every case there's no reason to change that value.</p>
1525 <p>If used with AJP this directive sets the maximum AJP packet size in
1526 bytes. If you change it from the default, you must also change the
1527 <code>packetSize</code> attribute of your AJP connector on the
1528 Tomcat side! The attribute <code>packetSize</code> is only available
1529 in Tomcat <code>5.5.20+</code> and <code>6.0.2+</code></p>
1530 <p>Normally it is not necessary to change the maximum packet size.
1531 Problems with the default value have been reported when sending
1532 certificates or certificate chains.</p>
1535 </directivesynopsis>
1538 <name>ProxyMaxForwards</name>
1539 <description>Maximium number of proxies that a request can be forwarded
1540 through</description>
1541 <syntax>ProxyMaxForwards <var>number</var></syntax>
1542 <default>ProxyMaxForwards -1</default>
1543 <contextlist><context>server config</context><context>virtual host</context>
1547 <p>The <directive>ProxyMaxForwards</directive> directive specifies the
1548 maximum number of proxies through which a request may pass, if there's no
1549 <code>Max-Forwards</code> header supplied with the request. This may
1550 be set to prevent infinite proxy loops, or a DoS attack.</p>
1552 <example><title>Example</title>
1553 <highlight language="config">
1558 <p>Note that setting <directive>ProxyMaxForwards</directive> is a
1559 violation of the HTTP/1.1 protocol (RFC2616), which forbids a Proxy
1560 setting <code>Max-Forwards</code> if the Client didn't set it.
1561 Earlier Apache httpd versions would always set it. A negative
1562 <directive>ProxyMaxForwards</directive> value, including the
1563 default -1, gives you protocol-compliant behaviour, but may
1564 leave you open to loops.</p>
1566 </directivesynopsis>
1569 <name>NoProxy</name>
1570 <description>Hosts, domains, or networks that will be connected to
1571 directly</description>
1572 <syntax>NoProxy <var>host</var> [<var>host</var>] ...</syntax>
1573 <contextlist><context>server config</context><context>virtual host</context>
1577 <p>This directive is only useful for Apache httpd proxy servers within
1578 intranets. The <directive>NoProxy</directive> directive specifies a
1579 list of subnets, IP addresses, hosts and/or domains, separated by
1580 spaces. A request to a host which matches one or more of these is
1581 always served directly, without forwarding to the configured
1582 <directive module="mod_proxy">ProxyRemote</directive> proxy server(s).</p>
1584 <example><title>Example</title>
1585 <highlight language="config">
1586 ProxyRemote * http://firewall.example.com:81
1587 NoProxy .example.com 192.168.112.0/21
1591 <p>The <var>host</var> arguments to the <directive>NoProxy</directive>
1592 directive are one of the following type list:</p>
1595 <!-- ===================== Domain ======================= -->
1596 <dt><var><a name="domain" id="domain">Domain</a></var></dt>
1598 <p>A <dfn>Domain</dfn> is a partially qualified DNS domain name, preceded
1599 by a period. It represents a list of hosts which logically belong to the
1600 same DNS domain or zone (<em>i.e.</em>, the suffixes of the hostnames are
1601 all ending in <var>Domain</var>).</p>
1603 <example><title>Examples</title>
1607 <p>To distinguish <var>Domain</var>s from <var><a href="#hostname"
1608 >Hostname</a></var>s (both syntactically and semantically; a DNS domain can
1609 have a DNS A record, too!), <var>Domain</var>s are always written with a
1612 <note><title>Note</title>
1613 <p>Domain name comparisons are done without regard to the case, and
1614 <var>Domain</var>s are always assumed to be anchored in the root of the
1615 DNS tree, therefore two domains <code>.ExAmple.com</code> and
1616 <code>.example.com.</code> (note the trailing period) are considered
1617 equal. Since a domain comparison does not involve a DNS lookup, it is much
1618 more efficient than subnet comparison.</p>
1621 <!-- ===================== SubNet ======================= -->
1622 <dt><var><a name="subnet" id="subnet">SubNet</a></var></dt>
1624 <p>A <dfn>SubNet</dfn> is a partially qualified internet address in
1625 numeric (dotted quad) form, optionally followed by a slash and the netmask,
1626 specified as the number of significant bits in the <var>SubNet</var>. It is
1627 used to represent a subnet of hosts which can be reached over a common
1628 network interface. In the absence of the explicit net mask it is assumed
1629 that omitted (or zero valued) trailing digits specify the mask. (In this
1630 case, the netmask can only be multiples of 8 bits wide.) Examples:</p>
1633 <dt><code>192.168</code> or <code>192.168.0.0</code></dt>
1634 <dd>the subnet 192.168.0.0 with an implied netmask of 16 valid bits
1635 (sometimes used in the netmask form <code>255.255.0.0</code>)</dd>
1636 <dt><code>192.168.112.0/21</code></dt>
1637 <dd>the subnet <code>192.168.112.0/21</code> with a netmask of 21
1638 valid bits (also used in the form <code>255.255.248.0</code>)</dd>
1641 <p>As a degenerate case, a <em>SubNet</em> with 32 valid bits is the
1642 equivalent to an <var><a href="#ipaddr">IPAddr</a></var>, while a <var>SubNet</var> with zero
1643 valid bits (<em>e.g.</em>, 0.0.0.0/0) is the same as the constant
1644 <var>_Default_</var>, matching any IP address.</p></dd>
1646 <!-- ===================== IPAddr ======================= -->
1647 <dt><var><a name="ipaddr" id="ipaddr">IPAddr</a></var></dt>
1649 <p>A <dfn>IPAddr</dfn> represents a fully qualified internet address in
1650 numeric (dotted quad) form. Usually, this address represents a host, but
1651 there need not necessarily be a DNS domain name connected with the
1653 <example><title>Example</title>
1657 <note><title>Note</title>
1658 <p>An <var>IPAddr</var> does not need to be resolved by the DNS system, so
1659 it can result in more effective apache performance.</p>
1662 <!-- ===================== Hostname ======================= -->
1663 <dt><var><a name="hostname" id="hostname">Hostname</a></var></dt>
1665 <p>A <dfn>Hostname</dfn> is a fully qualified DNS domain name which can
1666 be resolved to one or more <var><a href="#ipaddr">IPAddrs</a></var> via the
1667 DNS domain name service. It represents a logical host (in contrast to
1668 <var><a href="#domain">Domain</a></var>s, see above) and must be resolvable
1669 to at least one <var><a href="#ipaddr">IPAddr</a></var> (or often to a list
1670 of hosts with different <var><a href="#ipaddr">IPAddr</a></var>s).</p>
1672 <example><title>Examples</title>
1673 prep.ai.example.edu<br />
1677 <note><title>Note</title>
1678 <p>In many situations, it is more effective to specify an <var><a
1679 href="#ipaddr">IPAddr</a></var> in place of a <var>Hostname</var> since a
1680 DNS lookup can be avoided. Name resolution in Apache httpd can take a remarkable
1681 deal of time when the connection to the name server uses a slow PPP
1683 <p><var>Hostname</var> comparisons are done without regard to the case,
1684 and <var>Hostname</var>s are always assumed to be anchored in the root
1685 of the DNS tree, therefore two hosts <code>WWW.ExAmple.com</code>
1686 and <code>www.example.com.</code> (note the trailing period) are
1687 considered equal.</p>
1691 <seealso><a href="../dns-caveats.html">DNS Issues</a></seealso>
1692 </directivesynopsis>
1695 <name>ProxyTimeout</name>
1696 <description>Network timeout for proxied requests</description>
1697 <syntax>ProxyTimeout <var>seconds</var></syntax>
1698 <default>Value of <directive module="core">Timeout</directive></default>
1699 <contextlist><context>server config</context><context>virtual host</context>
1703 <p>This directive allows a user to specifiy a timeout on proxy requests.
1704 This is useful when you have a slow/buggy appserver which hangs, and you
1705 would rather just return a timeout and fail gracefully instead of waiting
1706 however long it takes the server to return.</p>
1708 </directivesynopsis>
1711 <name>ProxyDomain</name>
1712 <description>Default domain name for proxied requests</description>
1713 <syntax>ProxyDomain <var>Domain</var></syntax>
1714 <contextlist><context>server config</context><context>virtual host</context>
1718 <p>This directive is only useful for Apache httpd proxy servers within
1719 intranets. The <directive>ProxyDomain</directive> directive specifies
1720 the default domain which the apache proxy server will belong to. If a
1721 request to a host without a domain name is encountered, a redirection
1722 response to the same host with the configured <var>Domain</var> appended
1723 will be generated.</p>
1725 <example><title>Example</title>
1726 <highlight language="config">
1727 ProxyRemote * http://firewall.example.com:81<br />
1728 NoProxy .example.com 192.168.112.0/21<br />
1729 ProxyDomain .example.com
1733 </directivesynopsis>
1736 <name>ProxyVia</name>
1737 <description>Information provided in the <code>Via</code> HTTP response
1738 header for proxied requests</description>
1739 <syntax>ProxyVia On|Off|Full|Block</syntax>
1740 <default>ProxyVia Off</default>
1741 <contextlist><context>server config</context><context>virtual host</context>
1745 <p>This directive controls the use of the <code>Via:</code> HTTP
1746 header by the proxy. Its intended use is to control the flow of
1747 proxy requests along a chain of proxy servers. See <a
1748 href="http://www.ietf.org/rfc/rfc2616.txt">RFC 2616</a> (HTTP/1.1), section
1749 14.45 for an explanation of <code>Via:</code> header lines.</p>
1752 <li>If set to <code>Off</code>, which is the default, no special processing
1753 is performed. If a request or reply contains a <code>Via:</code> header,
1754 it is passed through unchanged.</li>
1756 <li>If set to <code>On</code>, each request and reply will get a
1757 <code>Via:</code> header line added for the current host.</li>
1759 <li>If set to <code>Full</code>, each generated <code>Via:</code> header
1760 line will additionally have the Apache httpd server version shown as a
1761 <code>Via:</code> comment field.</li>
1763 <li>If set to <code>Block</code>, every proxy request will have all its
1764 <code>Via:</code> header lines removed. No new <code>Via:</code> header will
1768 </directivesynopsis>
1771 <name>ProxyErrorOverride</name>
1772 <description>Override error pages for proxied content</description>
1773 <syntax>ProxyErrorOverride On|Off</syntax>
1774 <default>ProxyErrorOverride Off</default>
1775 <contextlist><context>server config</context><context>virtual host</context>
1776 <context>directory</context>
1780 <p>This directive is useful for reverse-proxy setups, where you want to
1781 have a common look and feel on the error pages seen by the end user.
1782 This also allows for included files (via
1783 <module>mod_include</module>'s SSI) to get
1784 the error code and act accordingly (default behavior would display
1785 the error page of the proxied server, turning this on shows the SSI
1788 <p>This directive does not affect the processing of informational (1xx),
1789 normal success (2xx), or redirect (3xx) responses.</p>
1791 </directivesynopsis>
1794 <name>ProxyPassInterpolateEnv</name>
1795 <description>Enable Environment Variable interpolation in Reverse Proxy configurations</description>
1796 <syntax>ProxyPassInterpolateEnv On|Off</syntax>
1797 <default>ProxyPassInterpolateEnv Off</default>
1798 <contextlist><context>server config</context>
1799 <context>virtual host</context>
1800 <context>directory</context>
1804 <p>This directive, together with the <var>interpolate</var> argument to
1805 <directive>ProxyPass</directive>, <directive>ProxyPassReverse</directive>,
1806 <directive>ProxyPassReverseCookieDomain</directive> and
1807 <directive>ProxyPassReverseCookiePath</directive>
1808 enables reverse proxies to be dynamically
1809 configured using environment variables, which may be set by
1810 another module such as <module>mod_rewrite</module>.
1811 It affects the <directive>ProxyPass</directive>,
1812 <directive>ProxyPassReverse</directive>,
1813 <directive>ProxyPassReverseCookieDomain</directive>, and
1814 <directive>ProxyPassReverseCookiePath</directive> directives,
1815 and causes them to substitute the value of an environment
1816 variable <code>varname</code> for the string <code>${varname}</code>
1817 in configuration directives (if the <var>interpolate</var> option is set).</p>
1818 <p>Keep this turned off (for server performance) unless you need it!</p>
1820 </directivesynopsis>
1823 <name>ProxyStatus</name>
1824 <description>Show Proxy LoadBalancer status in mod_status</description>
1825 <syntax>ProxyStatus Off|On|Full</syntax>
1826 <default>ProxyStatus Off</default>
1827 <contextlist><context>server config</context>
1828 <context>virtual host</context>
1832 <p>This directive determines whether or not proxy
1833 loadbalancer status data is displayed via the <module>mod_status</module>
1834 server-status page.</p>
1835 <note><title>Note</title>
1836 <p><strong>Full</strong> is synonymous with <strong>On</strong></p>
1840 </directivesynopsis>
1843 <name>ProxyAddHeaders</name>
1844 <description>Add proxy information in X-Forwarded-* headers</description>
1845 <syntax>ProxyAddHeaders Off|On</syntax>
1846 <default>ProxyAddHeaders On</default>
1847 <contextlist><context>server config</context>
1848 <context>virtual host</context>
1849 <context>directory</context>
1851 <compatibility>Available in version 2.3.10 and later</compatibility>
1854 <p>This directive determines whether or not proxy related information should be passed to the
1855 backend server through X-Forwarded-For, X-Forwarded-Host and X-Forwarded-Server HTTP headers.</p>
1856 <note><title>Effectiveness</title>
1857 <p>This option is of use only for HTTP proxying, as handled by <module>mod_proxy_http</module>.</p>
1860 </directivesynopsis>
1863 <name>ProxySourceAddress</name>
1864 <description>Set local IP address for outgoing proxy connections</description>
1865 <syntax>ProxySourceAddress <var>address</var></syntax>
1866 <contextlist><context>server config</context>
1867 <context>virtual host</context>
1869 <compatibility>Available in version 2.3.9 and later</compatibility>
1872 <p>This directive allows to set a specific local address to bind to when connecting
1873 to a backend server.</p>
1875 </directivesynopsis>