From: Rainer Jung Date: Tue, 5 Oct 2010 20:36:06 +0000 (+0000) Subject: Add information about proxy workers to proxy docs. X-Git-Tag: 2.2.17~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9ec660393828836874893c86f7f0edad9998975a;p=thirdparty%2Fapache%2Fhttpd.git Add information about proxy workers to proxy docs. Mostly a backport of r987858. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@1004805 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index f683c0fc07e..44015d93db4 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -128,6 +128,11 @@

In addition, if you wish to have caching enabled, consult the documentation from mod_cache.

+ Reverse Proxy + ProxyPass /foo http://foo.example.com/bar
+ ProxyPassReverse /foo http://foo.example.com/bar +
+ Forward Proxy ProxyRequests On
ProxyVia On
@@ -141,22 +146,125 @@ </Proxy>
- Reverse Proxy - ProxyRequests Off
-
- <Proxy *>
- - Order deny,allow
- Allow from all
-
- </Proxy>
-
- ProxyPass /foo http://foo.example.com/bar
- ProxyPassReverse /foo http://foo.example.com/bar -
+
Workers +

The proxy manages the configuration of origin servers and their + communication parameters in objects called workers. + There are two built-in workers, the default forward proxy worker and the + default reverse proxy worker. Additional workers can be configured + explicitly.

+ +

The two default workers have a fixed configuration + and will be used if no other worker matches the request. + They do not use HTTP Keep-Alive or connection pooling. + The TCP connections to the origin server will instead be + opened and closed for each request.

+ +

Explicitly configured workers are identified by their URL. + They are usually created and configured using + ProxyPass or + ProxyPassMatch when used + for a reverse proxy:

+ + + ProxyPass /example http://backend.example.com connectiontimeout=5 timeout=30 + + +

This will create a worker associated with the origin server URL + http://backend.example.com and using the given timeout + values. When used in a forward proxy, workers are usually defined + via the ProxySet directive:

+ + + ProxySet http://backend.example.com connectiontimeout=5 timeout=30 + + +

or alternatively using Proxy + and ProxySet:

+ + + <Proxy http://backend.example.com>
+ + ProxySet connectiontimeout=5 timeout=30 + + </Proxy> +
+ +

Using explicitly configured workers in the forward mode is + not very common, because forward proxies usually communicate with many + different origin servers. Creating explicit workers for some of the + origin servers can still be useful, if they are used very often. + Explicitly configured workers have no concept of forward or reverse + proxying by themselves. They encapsulate a common concept of + communication with origin servers. A worker created by + ProxyPass for use in a + reverse proxy will be also used for forward proxy requests whenever + the URL to the origin server matches the worker URL and vice versa.

+ +

The URL identifying a direct worker is the URL of its + origin server including any path components given:

+ + + ProxyPass /examples http://backend.example.com/examples
+ ProxyPass /docs http://backend.example.com/docs +
+ +

This example defines two different workers, each using a separate + connection pool and configuration.

+ + Worker Sharing +

Worker sharing happens if the worker URLs overlap, which occurs when + the URL of some worker is a leading substring of the URL of another + worker defined later in the configuration file. In the following example

+ + + ProxyPass /apps http://backend.example.com/ timeout=60
+ ProxyPass /examples http://backend.example.com/examples timeout=10 +
+ +

the second worker isn't actually created. Instead the first + worker is used. The benefit is, that there is only one connection pool, + so connections are more often reused. Note that all configuration attributes + given explicitly for the later worker and some configuration defaults will + overwrite the configuration given for the first worker. This will be logged + as a warning. In the above example the resulting timeout value + for the URL /apps will be 10 instead + of 60!

+ +

If you want to avoid worker sharing, sort your worker definitions + by URL length, starting with the longest worker URLs. If you want to maximize + worker sharing use the reverse sort order. See also the related warning about + ordering ProxyPass directives.

+ +
+ +

Explicitly configured workers come in two flavors: + direct workers and (load) balancer workers. + They support many important configuration attributes which are + described below in the ProxyPass + directive. The same attributes can also be set using + ProxySet.

+ +

The set of options available for a direct worker + depends on the protocol, which is specified in the origin server URL. + Available protocols include ajp, + ftp, http and scgi.

+ +

Balancer workers are virtual workers that use direct workers known + as their members to actually handle the requests. Each balancer can + have multiple members. When it handles a request, it chooses a member + based on the configured load balancing algorithm.

+ +

A balancer worker is created if its worker URL uses + balancer as the protocol scheme. + The balancer URL uniquely identifies the balancer worker. + Members are added to a balancer using + BalancerMember.

+ +
+
Controlling access to your proxy

You can control who can access your proxy via the Proxy control block as in @@ -336,6 +444,7 @@ +ProxyMatch @@ -400,6 +509,7 @@ proxied resources type="section">Proxy directive, except it matches URLs using regular expressions.

+Proxy @@ -639,10 +749,20 @@ expressions backend.example.com except requests made to /mirror/foo/i.

- Note -

Order is important: exclusions must come before the - general ProxyPass directive.

-
+ Ordering ProxyPass Directives +

The configured ProxyPass + and ProxyPassMatch + rules are checked in the order of configuration. The first rule that + matches wins. So usually you should sort conflicting + ProxyPass rules starting with the + longest URLs first. Otherwise later rules for longer URLS will be hidden + by any earlier rule which uses a leading substring of the URL. Note that + there is some relation with worker sharing.

+ +

For the same reasons exclusions must come before the + general ProxyPass directives.

+ +

As of Apache 2.1, the ability to use pooled connections to a backend server is available. Using the key=value parameters it is