⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_proxy.html

📁 这个是我在web培训时老师提供的手册
💻 HTML
📖 第 1 页 / 共 4 页
字号:
</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">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>转发请求的最大代理数目</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>ProxyMaxForwards <var>number</var></code></td></tr>
<tr><th><a href="directive-dict.html#Default">默认值</a></th><td><code>ProxyMaxForwards 10</code></td></tr>
<tr><th><a href="directive-dict.html#Context">作用域</a></th><td>server config, virtual host</td></tr>
<tr><th><a href="directive-dict.html#Status">状态</a></th><td>扩展(E)</td></tr>
<tr><th><a href="directive-dict.html#Module">模块</a></th><td>mod_proxy</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">兼容性</a></th><td>仅在 Apache 2.0 及以后的版本中可用</td></tr>
</table>
    <p><code class="directive">ProxyMaxForwards</code>指令指定了允许转发请求的最大代理数目。这个设置是为了避免无限代理循环或DoS攻击的发生。</p>

    <div class="example"><h3>示例</h3><p><code>
      ProxyMaxForwards 15
    </code></p></div>

</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">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>将一个远端服务器映射到本地服务器的URL空间中</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>ProxyPass [<var>path</var>] !|<var>url</var> [<var>key=value</var> <var>key=value</var> ...]]</code></td></tr>
<tr><th><a href="directive-dict.html#Context">作用域</a></th><td>server config, virtual host, directory</td></tr>
<tr><th><a href="directive-dict.html#Status">状态</a></th><td>扩展(E)</td></tr>
<tr><th><a href="directive-dict.html#Module">模块</a></th><td>mod_proxy</td></tr>
</table>
    <p>该指令允许你将一个远端服务器映射到本地服务器的URL空间中,此时本地服务器并不充当代理角色,而是充当远程服务器的一个镜像。<var>path</var>是一个本地虚拟路径名,<var>url</var>是一个指向远程服务器的部分URL,并且不允许包含查询字符串。</p>

    <div class="warning">当使用<code class="directive">ProxyPass</code>指令时,<code class="directive"><a href="#proxyrequests">ProxyRequests</a></code>指令通常应当被设为 <strong>off</strong> 。</div>

    <p>假设本地服务器地址是:<code>http://example.com/</code> ,那么,</p>

    <div class="example"><p><code>
      ProxyPass /mirror/foo/ http://backend.example.com/
    </code></p></div>

    <p>将会导致对<code>http://example.com/mirror/foo/bar</code>的本地请求将会在内部转换为一个代理请求:<code>http://backend.example.com/bar</code> 。</p>

    <p>"<code>!</code>"指令对于您不想对某个子目录进行反向代理时很有用。比如说:</p>

    <div class="example"><p><code>
      ProxyPass /mirror/foo/i !<br />
      ProxyPass /mirror/foo http://backend.example.com
    </code></p></div>

    <p>将会代理除<code>/mirror/foo/i</code>之外的所有对<code>backend.example.com</code>下<code>/mirror/foo</code>的请求。</p>

    <div class="note"><h3>注意</h3>
      <p>顺序很重要,您需要把拒绝指令放置在普通<code class="directive">ProxyPass</code>指令<em>之前</em>。</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 border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<tr><th>Parameter</th><th>Default</th><th>Description</th></tr>
<tr><td>min</td><td>0</td><td>Minumum 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>ttl</td><td>-</td><td>Time To Live for the inactive connections above the
        <code>smax</code> connections in seconds. Apache will close all
        connections that has not been used inside that time period.
    </td></tr>
<tr><td>timeout</td><td><code class="directive">Timeout</code></td><td>Connection timeout in seconds.
        If not set the Apache will wait until the free connection
        is available. This directive is used for limiting the number
        of connections to the backend server together with <code>max</code>
        parameter.
    </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. 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>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>retry</td><td>60</td><td>Connection pool worker retry timeout in seconds.
    If the connection pool worker to the backend server is in the error state,
    Apache will not forward any requests to that server until the timeout
    expires. This enables to shut down the backend server for maintenance,
    and bring it back online later.
    </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>route</td><td>-</td><td>Route of the worker when used inside load balancer.
        The route is a value appended to seesion id.
    </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.
    </td></tr>
</table>

    <p>If the Proxy directive scheme starts with the
    <code>balancer://</code> then a virtual worker that does not really
    communicate with the backend server will be created. Instead it is responsible
    for the management of several "real" workers. In that case the special set of
    parameters can be add to this virtual worker.
    </p>
    <table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA">
<tr><th>Parameter</th><th>Default</th><th>Description</th></tr>
<tr><td>lbmethod</td><td>-</td><td>Balancer load-balance method. Select the load-balancing scheduler
        method to use. Either <code>byrequests</code>, to perform weighted
        request counting or <code>bytraffic</code>, to perform weighted
        traffic byte count balancing. Default is <code>byrequests</code>.
    </td></tr>
<tr><td>stickysession</td><td>-</td><td>Balancer sticky session name. The value is usually set to something
        like <code>JSESSIONID</code>或<code>PHPSESSIONID</code>,
        and it depends on the backend application server that support sessions.
    </td></tr>
<tr><td>nofailover</td><td>Off</td><td>If set to <code>On</code> the session will break if the worker is in
        error state or disabled. Set this value to On if backend servers do not
        support session replication.
    </td></tr>
<tr><td>timeout</td><td>0</td><td>Balancer timeout in seconds. If set this will be the maximum time
        to wait for a free worker. Default is not to wait. 
    </td></tr>
<tr><td>maxattempts</td><td>1</td><td>Maximum number of failover attempts before giving up. 
    </td></tr>
</table>
    <div class="example"><p><code>
      ProxyPass /special-area http://special.example.com/ smax=5 max=10<br />
      ProxyPass / balancer://mycluster stickysession=jsessionid nofailover=On<br />
      &lt;Proxy balancer://mycluster&gt;<br />
      <span class="indent">
        BalancerMember http://1.2.3.4:8009<br />
        BalancerMember http://1.2.3.5:8009 smax=10<br />
        # Less powerful server, don't send as many requests there<br />
        BalancerMember http://1.2.3.6:8009 smax=1 loadfactor=20<br />
      </span>
      &lt;/Proxy&gt;
    </code></p></div>
    
    <p>When used inside a <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code> section, the first argument is omitted and the local
    directory is obtained from the <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code>.</p>

    <p>If you require a more flexible reverse-proxy configuration, see the
    <code class="directive"><a href="../mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> directive with the
    <code>[P]</code> flag.</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="ProxyPassReverse" id="ProxyPassReverse">ProxyPassReverse</a> <a name="proxypassreverse" id="proxypassreverse">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>调整由反向代理服务器发送的HTTP应答头中的URL</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>ProxyPassReverse [<var>path</var>] <var>url</var></code></td></tr>
<tr><th><a href="directive-dict.html#Context">作用域</a></th><td>server config, virtual host, directory</td></tr>
<tr><th><a href="directive-dict.html#Status">状态</a></th><td>扩展(E)</td></tr>
<tr><th><a href="directive-dict.html#Module">模块</a></th><td>mod_proxy</td></tr>
</table>
    <p>此指令使Apache调整HTTP重定向应答中<code>Location</code>, <code>Content-Location</code>, <code>URI</code>头里的URL。这样可以避免在Apache作为反向代理使用时,后端服务器的HTTP重定向造成的绕过反向代理的问题。</p>

    <p>只有明确指定的应答头会被重写,其它应答头保持不变,并且HTML页面中的URL也不会被修改。如果被代理的内容包含绝对URL引用,那么将会绕过代理。有一个第三方模块可以检查并改写HTML中的URL引用,该模块就是Nick
    Kew编写的<a href="http://apache.webthing.com/mod_proxy_html/">mod_proxy_html</a>。</p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -