1N/A<!
DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
1N/A<
TITLE>Apache module mod_proxy</
TITLE>
1N/A<
H1>Apache module mod_proxy</
h1>
1N/Ais not compiled in by default. It provides for a caching proxy server.
1N/AIt is only available in Apache 1.1 and later. Common configuration
1N/Aquestions are addressed <
a href="#configs">here</
a>.
1N/A<
p>This module was experimental in Apache
1.1.x. As of Apache 1.2, mod_proxy
1N/Astability is <
i>greatly</
i> improved.<
p>
1N/Aproxying capability for
1N/A<
code>CONNECT</
code> (for SSL),
1N/AThe module can be configured to connect to other proxy modules for these
1N/A<
li><
a href="#proxyrequests">ProxyRequests</
a>
1N/A<
li><
a href="#proxyremote">ProxyRemote</
a>
1N/A<
li><
a href="#proxypass">ProxyPass</
a>
1N/A<
li><
a href="#proxyblock">ProxyBlock</
a>
1N/A<
li><
a href="#cacheroot">CacheRoot</
a>
1N/A<
li><
a href="#cachesize">CacheSize</
a>
1N/A<
li><
a href="#cachegcinterval">CacheGcInterval</
a>
1N/A<
li><
a href="#cachemaxexpire">CacheMaxExpire</
a>
1N/A<
li><
a href="#cachelastmodifiedfactor">CacheLastModifiedFactor</
a>
1N/A<
li><
a href="#cachedefaultexpire">CacheDefaultExpire</
a>
1N/A<
li><
a href="#nocache">NoCache</
a>
1N/A<
A name="proxyrequests"><
h2>ProxyRequests</
h2></
A>
1N/A<
strong>Syntax:</
strong> ProxyRequests <
em>
on/
off</
em><
br>
1N/A<
strong>Default:</
strong> <
code>ProxyRequests Off</
code><
br>
1N/A<
strong>Context:</
strong> server config<
br>
1N/A<
strong>Status:</
strong> Base<
br>
1N/A<
strong>Module:</
strong> mod_proxy<
br>
1N/A<
strong>Compatibility:</
strong> ProxyRequest is only available in
1N/AApache 1.1 and later.<
p>
1N/AThis allows or prevents Apache from functioning as a proxy
1N/Aserver. Setting ProxyRequests to 'off' does not disable use of the <
a 1N/Ahref="#proxypass">ProxyPass</
a> directive.
1N/A<
A name="proxyremote"><
h2>ProxyRemote</
h2></
A>
1N/A<
strong>Syntax:</
strong> ProxyRemote <
em><match> <remote-server></
em><
br>
1N/A<
strong>Context:</
strong> server config<
br>
1N/A<
strong>Status:</
strong> Base<
br>
1N/A<
strong>Module:</
strong> mod_proxy<
br>
1N/A<
strong>Compatibility:</
strong> ProxyRemote is only available in
1N/AApache 1.1 and later.<
p>
1N/AThis defines remote proxies to this proxy. <match> is either the
1N/Aname of a URL-scheme that the remote server supports, or a partial URL
1N/Afor which the remote server should be used, or '*' to indicate the
1N/Aserver should be contacted for all requests. <remote-server> is a
1N/Apartial URL for the remote server. Syntax:
1N/A <remote-server> = <protocol>://<hostname>[:port]
1N/A<protocol> is the protocol that should be used to communicate
1N/Awith the remote server; only "http" is supported by this module.
1N/AIn the last example, the proxy will forward FTP requests, encapsulated
1N/Aas yet another HTTP proxy request, to another proxy which can handle
1N/Athem. Apache itself can not directly handle FTP requests currently.
1N/A<
A name="proxypass"><
h2>ProxyPass</
h2></
A>
1N/A<
strong>Syntax:</
strong> ProxyPass <
em><path> <url></
em><
br>
1N/A<
strong>Context:</
strong> server config<
br>
1N/A<
strong>Status:</
strong> Base<
br>
1N/A<
strong>Module:</
strong> mod_proxy<
br>
1N/A<
strong>Compatibility:</
strong> ProxyPass is only available in
1N/AApache 1.1 and later.<
p>
1N/AThis directive allows remote servers to be mapped into the space of the local
1N/Aserver; the local server does not act as a proxy in the conventional sense,
1N/Abut appears to be a mirror of the remote server. <path> is the name of
1N/Aa local virtual path; <url> is a partial URL for the remote server.
1N/A<
A name="proxyblock"><
h2>ProxyBlock</
h2></
A>
1N/A<
strong>Context:</
strong> server config<
br>
1N/A<
strong>Status:</
strong> Base<
br>
1N/A<
strong>Module:</
strong> mod_proxy<
br>
1N/A<
strong>Compatibility:</
strong> ProxyBlock is only available in
1N/AApache 1.2 and later.<
p>
1N/AThe ProxyBlock directive specifies a list of words, hosts
and/
or domains,
1N/Aseparated by spaces. HTTP, HTTPS, and FTP document requests to matched words,
1N/Ahosts or domains are <
em>blocked</
em> by the proxy server. The proxy module
1N/Awill also attempt to determine IP addresses of list items which may be
1N/Ahostnames during startup, and cache them for match test as well. Example:
blocks connections to all sites.
<
A name="cacheroot"><
h2>CacheRoot</
h2></
A>
<
strong>Syntax:</
strong> CacheRoot <
em><directory></
em><
br>
<
strong>Context:</
strong> server config<
br>
<
strong>Status:</
strong> Base<
br>
<
strong>Module:</
strong> mod_proxy<
br>
<
strong>Compatibility:</
strong> CacheRoot is only available in
Sets the name of the directory to contain cache files; this must be
<
A name="cachesize"><
h2>CacheSize</
h2></
A>
<
strong>Syntax:</
strong> CacheSize <
em><size></
em><
br>
<
strong>Default:</
strong> <
code>CacheSize 5</
code><
br>
<
strong>Context:</
strong> server config<
br>
<
strong>Status:</
strong> Base<
br>
<
strong>Module:</
strong> mod_proxy<
br>
<
strong>Compatibility:</
strong> CacheSize is only available in
Sets the desired space usage of the cache, in Kb (1024 byte units). Although
usage may grow above this setting, the garbage collection will delete files
until the usage is at or below this setting.
<
A name="cachegcinterval"><
h2>CacheGcInterval</
h2></
A>
<
strong>Syntax:</
strong> CacheGcInterval <
em><time></
em><
br>
<
strong>Context:</
strong> server config<
br>
<
strong>Status:</
strong> Base<
br>
<
strong>Module:</
strong> mod_proxy<
br>
<
strong>Compatibility:</
strong> CacheGcinterval is only available in
Check the cache every <time> hours, and delete files if the space
usage is greater than that set by CacheSize.
<
A name="cachemaxexpire"><
h2>CacheMaxExpire</
h2></
A>
<
strong>Syntax:</
strong> CacheMaxExpire <
em><time></
em><
br>
<
strong>Default:</
strong> </
code>CacheMaxExpire 24</
code><
br>
<
strong>Context:</
strong> server config<
br>
<
strong>Status:</
strong> Base<
br>
<
strong>Module:</
strong> mod_proxy<
br>
<
strong>Compatibility:</
strong> CacheMaxExpire is only available in
Cachable HTTP documents will be retained for at most <time> hours without
checking the origin server. Thus documents can be at most <time>
hours out of date. This restriction is enforced even if an expiry date
was supplied with the document.
<
A name="cachelastmodifiedfactor"><
h2>CacheLastModifiedFactor</
h2></
A>
<
strong>Syntax:</
strong> CacheLastModifiedFactor <
em><factor></
em><
br>
<
strong>Default:</
strong> </
code>CacheLastModifiedFactor 0.1</
code><
br>
<
strong>Context:</
strong> server config<
br>
<
strong>Status:</
strong> Base<
br>
<
strong>Module:</
strong> mod_proxy<
br>
<
strong>Compatibility:</
strong> CacheLastModified is only available in
If the origin HTTP server did not supply an expiry date for the
document, then estimate on using the formula
expiry-period = time-since-last-modification * <factor>
For example, if the document was last modified 10 hours ago, and
<factor> is 0.1, then the expiry period will be set to 10*0.1 = 1 hour.
<
p>If the expiry-period would be longer than that set by CacheMaxExpire,
then the latter takes precedence.
<
A name="cachedefaultexpire"><
h2>CacheDefaultExpire</
h2></
A>
<
strong>Syntax:</
strong> CacheDefaultExpire <
em><time></
em><
br>
<
strong>Default:</
strong> </
code>CacheDefaultExpire 1</
code><
br>
<
strong>Context:</
strong> server config<
br>
<
strong>Status:</
strong> Base<
br>
<
strong>Module:</
strong> mod_proxy<
br>
<
strong>Compatibility:</
strong> CacheDefaultExpire is only available in
If the document is fetched via a protocol that does not support expirytimes,
then use <time> hours as the expiry time.
<
a href="#cachemaxexpire">CacheMaxExpire</
a> does <
strong>not</
strong>
<
A name="nocache"><
h2>NoCache</
h2></
A>
<
strong>Syntax:</
strong> NoCache <
em><
word/
host/
domain list></
em><
br>
<
strong>Context:</
strong> server config<
br>
<
strong>Status:</
strong> Base<
br>
<
strong>Module:</
strong> mod_proxy<
br>
<
strong>Compatibility:</
strong> NoCache is only available in
The NoCache directive specifies a list of words, hosts
and/
or domains, separated
by spaces. HTTP and non-passworded FTP documents from matched words, hosts or
domains are <
em>not</
em> cached by the proxy server. The proxy module will
also attempt to determine IP addresses of list items which may be hostnames
during startup, and cache them for match test as well. Example:
Note that 'wotsamattau' would also be sufficient to match '
wotsamattau.edu'.<
p>
disables caching completely.<
p>
<
a name="configs"><
h2>Common configuration topics</
h2></
a>
<
li><
a href="#access">Controlling access to your proxy</
a>
<
li><
a href="#shortname">Using Netscape hostname shortcuts</
a>
<
li><
a href="#mimetypes">Why doesn't file type <
i>xxx</
i> download via FTP?</
a>
<
li><
a href="#startup">Why does Apache start more slowly when using the
<
li><
a href="#socks">Can I use the Apache proxy module with my SOCKS proxy?</
a>
<
a name="access"><
h2>Controlling access to your proxy</
h2>
You can control who can access your proxy via the normal <Directory>
control block using the following example:<
p>
<Directory proxy:*>
deny from [machines you'd like not to allow by IP address or name]
<
a name="shortname"><
h2>Using Netscape hostname shortcuts</
h2>
There is an optional patch to the proxy module to allow Netscape-like
hostname shortcuts to be used. It's available
<
a name="mimetypes"><
h2>Why doesn't file type <
i>xxx</
i> download via FTP?</
h2>
You probably don't have that particular file type defined as
file. A useful line can be<
p>
<
a name="startup"><
h2>Why does Apache start more slowly when using the
If you're using the <
code>ProxyBlock</
code> or <
code>NoCache</
code>
directives, hostnames' IP addresses are looked up and cached during
startup for later match test. This may take a few seconds (or more)
depending on the speed with which the hostname lookups occur.<
p>
<
a name="socks"><
h2>Can I use the Apache proxy module with my SOCKS proxy?</
h2>
Yes. Just build Apache with the rule <
code>SOCKS4=yes</
code> in your
<
i>Configuration</
i> file, and follow the instructions there. SOCKS5
capability can be added in a similar way (there's no <
code>SOCKS5</
code>
rule yet, so use the <
code>EXTRA_LFLAGS</
code> definition, or build Apache
normally and run it with the <
i>runsocks</
i> wrapper provided with SOCKS5,
if your OS supports dynamically linked libraries.<
p>
Remember that you'll also have to grant access to your Apache proxy machine by
permitting connections on the appropriate ports in your SOCKS daemon's