📄 mod_proxy.html.en
字号:
<div class="directive-section"><h2><a name="ProxyMatch" id="ProxyMatch"><ProxyMatch></a> <a name="proxymatch" id="proxymatch">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Container for directives applied to regular-expression-matched proxied resources</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code><ProxyMatch <var>regex</var>> ...</ProxyMatch></code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy</td></tr></table> <p>The <code class="directive"><ProxyMatch></code> directive is identical to the <code class="directive"><a href="#proxy"><Proxy></a></code> directive, except it matches URLs using <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="ProxyMaxForwards" id="ProxyMaxForwards">ProxyMaxForwards</a> <a name="proxymaxforwards" id="proxymaxforwards">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maximium number of proxies that a request can be forwardedthrough</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ProxyMaxForwards <var>number</var></code></td></tr><tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>ProxyMaxForwards -1</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy</td></tr><tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Available in Apache 2.0 and later; default behaviour changed in 2.2.7</td></tr></table> <p>The <code class="directive">ProxyMaxForwards</code> directive specifies the maximum number of proxies through which a request may pass, if there's no <code>Max-Forwards</code> header supplied with the request. This may be set to prevent infinite proxy loops, or a DoS attack.</p> <div class="example"><h3>Example</h3><p><code> ProxyMaxForwards 15 </code></p></div> <p>Note that setting <code class="directive">ProxyMaxForwards</code> is a violation of the HTTP/1.1 protocol (RFC2616), which forbids a Proxy setting <code>Max-Forwards</code> if the Client didn't set it. Earlier Apache versions would always set it. A negative <code class="directive">ProxyMaxForwards</code> value, including the default -1, gives you protocol-compliant behaviour, but may leave you open to loops.</p></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="directive-section"><h2><a name="ProxyPass" id="ProxyPass">ProxyPass</a> <a name="proxypass" id="proxypass">Directive</a></h2><table class="directive"><tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps remote servers into the local server URL-space</td></tr><tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ProxyPass [<var>path</var>] !|<var>url</var> [<var>key=value</var><var>key=value</var> ...]] [nocanon] [interpolate]</code></td></tr><tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory</td></tr><tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr><tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_proxy</td></tr></table> <p>This directive allows remote servers to be mapped into the space of the local server; the local server does not act as a proxy in the conventional sense, but appears to be a mirror of the remote server. The local server is often called a <dfn>reverse proxy</dfn> or <dfn>gateway</dfn>. The <var>path</var> is the name of a local virtual path; <var>url</var> is a partial URL for the remote server and cannot include a query string.</p> <div class="warning">The <code class="directive"><a href="#proxyrequests">ProxyRequests</a></code> directive should usually be set <strong>off</strong> when using <code class="directive">ProxyPass</code>.</div> <p>Suppose the local server has address <code>http://example.com/</code>; then</p> <div class="example"><p><code> ProxyPass /mirror/foo/ http://backend.example.com/ </code></p></div> <p>will cause a local request for <code>http://example.com/mirror/foo/bar</code> to be internally converted into a proxy request to <code>http://backend.example.com/bar</code>.</p> <div class="warning"> <p>If the first argument ends with a trailing <strong>/</strong>, the second argument should also end with a trailing <strong>/</strong> and vice versa. Otherwise the resulting requests to the backend may miss some needed slashes and do not deliver the expected results. </p> </div> <p>The <code>!</code> directive is useful in situations where you don't want to reverse-proxy a subdirectory, <em>e.g.</em></p> <div class="example"><p><code> ProxyPass /mirror/foo/i !<br /> ProxyPass /mirror/foo http://backend.example.com </code></p></div> <p>will proxy all requests to <code>/mirror/foo</code> to <code>backend.example.com</code> <em>except</em> requests made to <code>/mirror/foo/i</code>.</p> <div class="note"><h3>Note</h3> <p>Order is important: exclusions must come <em>before</em> the general <code class="directive">ProxyPass</code> directive.</p> </div> <p>As of Apache 2.1, the ability to use pooled connections to a backend server is available. Using the <code>key=value</code> parameters it is possible to tune this connection pooling. The default for a <code>Hard Maximum</code> for the number of connections is the number of threads per process in the active MPM. In the Prefork MPM, this is always 1, while with the Worker MPM it is controlled by the <code class="directive">ThreadsPerChild</code>.</p> <p>Setting <code>min</code> will determine how many connections will always be open to the backend server. Upto the Soft Maximum or <code>smax</code> number of connections will be created on demand. Any connections above <code>smax</code> are subject to a time to live or <code>ttl</code>. Apache will never create more than the Hard Maximum or <code>max</code> connections to the backend server.</p> <div class="example"><p><code> ProxyPass /example http://backend.example.com smax=5 max=20 ttl=120 retry=300 </code></p></div> <table> <tr><th>Parameter</th> <th>Default</th> <th>Description</th></tr> <tr><td>min</td> <td>0</td> <td>Minimum number of connections that will always be open to the backend server.</td></tr> <tr><td>max</td> <td>1...n</td> <td>Hard Maximum number of connections that will be allowed to the backend server. The default for a Hard Maximum for the number of connections is the number of threads per process in the active MPM. In the Prefork MPM, this is always 1, while with the Worker MPM it is controlled by the <code class="directive">ThreadsPerChild</code>. Apache will never create more than the Hard Maximum connections to the backend server.</td></tr> <tr><td>smax</td> <td>max</td> <td>Upto the Soft Maximum number of connections will be created on demand. Any connections above <code>smax</code> are subject to a time to live or <code>ttl</code>. </td></tr> <tr><td>acquire</td> <td>-</td> <td>If set this will be the maximum time to wait for a free connection in the connection pool, in milliseconds. If there are no free connections in the pool the Apache will return <code>SERVER_BUSY</code> status to the client. </td></tr> <tr><td>connectiontimeout</td> <td>timeout</td> <td>Connect timeout in seconds. The number of seconds Apache waits for the creation of a connection to the backend to complete. By adding a postfix of ms the timeout can be also set in milliseconds. </td></tr> <tr><td>disablereuse</td> <td>Off</td> <td>This parameter should be used when you want to force mod_proxy to immediately close a connection to the backend after being used, and thus, disable its persistent connection and pool for that backend. This helps in various situations where a firewall between Apache and the backend server (regardless of protocol) tends to silently drop connections or when backends themselves may be under round- robin DNS. To disable connection pooling reuse, set this property value to <code>On</code>. </td></tr> <tr><td>flushpackets</td> <td>off</td> <td>Determines whether the proxy module will auto-flush the output brigade after each "chunk" of data. 'off' means that it will flush only when needed, 'on' means after each chunk is sent and 'auto' means poll/wait for a period of time and flush if no input has been received for 'flushwait' milliseconds. Currently this is in effect only for AJP. </td></tr> <tr><td>flushwait</td> <td>10</td> <td>The time to wait for additional input, in milliseconds, before flushing the output brigade if 'flushpackets' is 'auto'. </td></tr> <tr><td>keepalive</td> <td>Off</td> <td>This parameter should be used when you have a firewall between your Apache and the backend server, who tend to drop inactive connections. This flag will tell the Operating System to send <code>KEEP_ALIVE</code> messages on inactive connections (interval depends on global OS settings, generally 120ms), and thus prevent the firewall to drop the connection. To enable keepalive set this property value to <code>On</code>. </td></tr> <tr><td>lbset</td> <td>0</td> <td>Sets the load balancer cluster set that the worker is a member of. The load balancer will try all members of a lower numbered lbset before trying higher numbered ones. </td></tr> <tr><td>ping</td> <td>0</td> <td>Ping property tells webserver to send a <code>CPING</code> request on ajp13 connection before forwarding a request. The parameter is the delay in seconds to wait for the <code>CPONG</code> reply. This features has been added to avoid problem with hung and busy Tomcat's and require ajp13 ping/pong support which has been implemented on Tomcat 3.3.2+, 4.1.28+ and 5.0.13+. This will increase the network traffic during the normal operation which could be an issue, but it will lower the traffic in case some of the cluster nodes are down or busy. Currently this has an effect only for AJP. By adding a postfix of ms the delay can be also set in milliseconds. </td></tr> <tr><td>loadfactor</td> <td>1</td> <td>Worker load factor. Used with BalancerMember. It is a number between 1 and 100 and defines the normalized weighted load applied to the worker. </td></tr> <tr><td>redirect</td> <td>-</td> <td>Redirection Route of the worker. This value is usually set dynamically to enable safe removal of the node from the cluster. If set all requests without session id will be redirected to the BalancerMember that has route parametar equal as this value.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -