Apache HTTP Server 版本2.2

| 說明 | 提供HTTP/1.1的代理/網(wǎng)關功能支持 |
|---|---|
| 狀態(tài) | 擴展(E) |
| 模塊名 | proxy_module |
| 源文件 | mod_proxy.c |
在您沒有對服務器采取安全措施之前,請不要用ProxyRequests啟用代理。一個開放的代理服務器不僅對您的網(wǎng)絡有威脅,對整個因特網(wǎng)來說也同樣如此。
此模塊實現(xiàn)了Apache的代理/網(wǎng)關。它實現(xiàn)了以下規(guī)范的代理:AJP13(Apache JServe Protocol v1.3), FTP, CONNECT(用于SSL), HTTP/0.9, HTTP/1.0, HTTP/1.1 。此模塊經(jīng)配置后可用上述或其它協(xié)議連接其它代理模塊。
Apache的代理功能(除mod_proxy以外)被劃分到了幾個不同的模塊中:mod_proxy_http, mod_proxy_ftp, mod_proxy_ajp, mod_proxy_balancer, mod_proxy_connect 。這樣,如果想使用一個或多個代理功能,就必須將mod_proxy和對應的模塊同時加載到服務器中(靜態(tài)連接或用LoadModule動態(tài)加載)。
另外,其它模塊還提供了擴展特性。mod_cache及其相關模塊提供了緩沖特性。mod_ssl提供的SSLProxy*系列指令可以使用SSL/TLS連接遠程服務器。這些提供擴展特性的模塊必須在被正確加載和配置以后才能提供這些擴展功能。
Apache可以被配置為正向(forward)和反向(reverse)代理。
正向代理是一個位于客戶端和原始服務器(origin server)之間的服務器,為了從原始服務器取得內(nèi)容,客戶端向代理發(fā)送一個請求并指定目標(原始服務器),然后代理向原始服務器轉(zhuǎn)交請求并將獲得的內(nèi)容返回給客戶端?蛻舳吮仨氁M行一些特別的設置才能使用正向代理。
正向代理的典型用途是為在防火墻內(nèi)的局域網(wǎng)客戶端提供訪問Internet的途徑。正向代理還可以使用緩沖特性(由mod_cache提供)減少網(wǎng)絡使用率。
使用ProxyRequests指令即可激活正向代理。因為正向代理允許客戶端通過它訪問任意網(wǎng)站并且隱藏客戶端自身,因此你必須采取安全措施以確保僅為經(jīng)過授權的客戶端提供服務。
反向代理正好相反,對于客戶端而言它就像是原始服務器,并且客戶端不需要進行任何特別的設置?蛻舳讼蚍聪虼淼拿挚臻g(name-space)中的內(nèi)容發(fā)送普通請求,接著反向代理將判斷向何處(原始服務器)轉(zhuǎn)交請求,并將獲得的內(nèi)容返回給客戶端,就像這些內(nèi)容原本就是它自己的一樣。
反向代理的典型用途是將防火墻后面的服務器提供給Internet用戶訪問。反向代理還可以為后端的多臺服務器提供負載平衡,或為后端較慢的服務器提供緩沖服務。另外,還可以啟用高級URL策略和管理技術,從而使處于不同web服務器系統(tǒng)的web頁面同時存在于同一個URL空間下。
可以使用ProxyPass指令激活反向代理(在RewriteRule指令中使用[P]標記也可以)。配置反向代理并不需要打開ProxyRequests指令。
下面的例子僅僅是為了給你一個基本概念而幫助入門而已,請仔細閱讀每個指令的文檔。
另外,如果想使用緩沖特性,請查看mod_cache文檔。
ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Deny from all
Allow from internal.example.com
</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
您可以通過<Proxy>的阻止功能來控制誰能訪問您的代理。示例如下:
<Proxy *>
Order Deny,Allow
Deny from all
Allow from 192.168.0
</Proxy>
要了解更多訪問控制信息,請參見mod_authz_host文檔。
使用正向代理時嚴格控制訪問權限(使用ProxyRequests指令)是非常重要的。否則你的代理會被客戶端利用來訪問其它服務器并且隱藏客戶端的真實身份。這不僅對您的網(wǎng)絡有威脅,對整個因特網(wǎng)來說也同樣如此。當使用反向代理(在"ProxyRequests Off"條件下使用ProxyPass指令)的時候訪問控制要相對寬松,因為客戶端只能連接你配置的特定主機。
如果您使用了ProxyBlock指令,將會在啟動時查找并緩存主機名的IP地址以備后繼的匹配測試使用。這將會花費幾秒或更長的時間,這主要取決于主機名查找的速度。
位于局域網(wǎng)內(nèi)的Apache代理服務器需要經(jīng)由公司的防火墻轉(zhuǎn)發(fā)對外部的請求(使用ProxyRemote指令來配置)。但當它訪問局域網(wǎng)內(nèi)的資源時,它能越過防火墻直接訪問目的主機。在訪問一個屬于局域網(wǎng)的服務器從而進行直接連接時,NoProxy指令就會很有用。
局域網(wǎng)內(nèi)的用戶習慣于不在他們的WWW請求中加入本地域的名稱,于是會使用"http://somehost/"來取代http://somehost.example.com/ 。一些商業(yè)代理服務器會不管這些,只是采用本地域的配置來簡單的伺服這個請求。當使用了ProxyDomain指令來為服務器配置了一個代理服務時,Apache會發(fā)出一個重定向應答,以使客戶端請求到達正確的、能滿足要求的服務器地址。因為這樣一來,用戶的書簽文件就會隨之包含完整的主機名,所以這是首選的方法。
當mod_proxy向一個沒有正確實現(xiàn)持久連接(KeepAlive)或HTTP/1.1的原始服務器發(fā)送請求的時候,可以通過設置兩個環(huán)境變量來發(fā)送不帶持久連接(KeepAlive)的HTTP/1.0請求。這兩個變量是通過SetEnv指令設置的。
以下是force-proxy-request-1.0和proxy-nokeepalive的例子:
<Location /buggyappserver/>
ProxyPass http://buggyappserver:7001/foo/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</Location>
一些請求方法(如POST)包含一個請求體。HTTP協(xié)議要求包含請求體的請求或者使用塊傳輸編碼(chunked transfer encoding)或者包含一個Content-Length請求頭。當將這種請求傳遞給原始服務器的時候,mod_proxy_http會始終嘗試使用Content-Length請求頭。但如果原始請求使用的是塊編碼,那么塊編碼也同樣可以用于上行請求。可以使用環(huán)境變量控制這種選擇。設置proxy-sendcl可以確保始終發(fā)送Content-Length頭以與上游服務器保持最大程度的兼容性,而設置proxy-sendchunked可以通過繼續(xù)使用塊編碼以盡可能最小化資源占用率。
| 說明 | 通過代理允許CONNECT的端口號 |
|---|---|
| 語法 | AllowCONNECT port [port] ... |
| 默認值 | AllowCONNECT 443 563 |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
AllowCONNECT指令指定了此代理的CONNECT方法可以連接的端口號列表。當今的瀏覽器在進行https連接請求時使用這種方法,而代理默認會將其轉(zhuǎn)為http。
默認只啟用了默認的https端口(443)和默認的snews端口(563)。使用AllowCONNECT指令可以覆蓋默認設置而改為僅允許連接列出的端口。
注意,必須確保mod_proxy_connect也同時存在于服務器中,這樣才能支持CONNECT 。
| 說明 | 直接進行連接的主機/域/網(wǎng)絡 |
|---|---|
| 語法 | NoProxy host [host] ... |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
此指令僅適用于局域網(wǎng)內(nèi)的Apache代理服務器。NoProxy指令指定了一個中間以空格分隔的子網(wǎng)、IP地址、主機和/或域的列表。對某個匹配上述一個或多個列表項的主機的請求將直接被其伺服而不會轉(zhuǎn)交到配置好的ProxyRemote代理服務器。
ProxyRemote * http://firewall.mycompany.com:81
NoProxy .mycompany.com 192.168.112.0/21
NoProxy指令的host參數(shù)可以是以下選項之一:
域是一個DNS域名的一部分,并在前面加上點號。它表示一批邏輯上屬于同一個DNS區(qū)域的主機,也就是所有這些主機名具有相同的后綴,而這個"后綴"就是域。
.com
.apache.org.
域和主機名(一個DNS域甚至也可能有一條DNS"A記錄"!)的不同之處在于域始終有一個前導點。
域名不區(qū)分大小寫并且始終認為是錨定在DNS樹根上的,因此.MyDomain.com和.mydomain.com.(注意結(jié)尾點號)是完全等同的。因為域的比較不需要進行DNS查詢,因此它比子網(wǎng)比較更加高效。
子網(wǎng)以點分十進制形式表示了一個因特網(wǎng)地址的一部分,有時會跟著一個斜杠和子網(wǎng)掩碼,以指定子網(wǎng)中的有效bit位。它用于表示主機通過自身的普通網(wǎng)絡接口可以訪問的子網(wǎng)范圍。未指定子網(wǎng)掩碼的時候就假定忽略掉的(或為零的)結(jié)尾數(shù)字就是掩碼,在這種情況下,掩碼bit長度必須是8bit的整數(shù)倍。例如:
192.168或192.168.0.0192.168.0.0"表示掩碼為16bit(有時也用255.255.0.0表示)。192.168.112.0/21192.168.112.0/21"表示掩碼為21bit(有時也用255.255.248.0表示)。在退化到極限的情況下,一個掩碼為32bit的子網(wǎng)就等價于一個IP地址。而零個合法bit的子網(wǎng)("0.0.0.0/0")等價于常量"_Default_",可以匹配任何IP地址。
IP地址以點分十進制形式表示了一個完整的因特網(wǎng)地址。一般來說,此地址代表一個主機,但并不需要一個DNS域名與這個地址對應。
192.168.123.7
一個IP地址不需要為一個DNS系統(tǒng)所解析,所以它能使apache獲取更高性能。
主機名是一個完整的DNS域名,可以通過DNS域名服務解析為一個或多個IP地址。它代表了一個邏輯主機(與域相反)而且必須解析成至少一個IP地址(或經(jīng)常解析成具有不同IP地址的主機列表)。
prep.ai.mit.edu
www.apache.org
在很多情況下,指定一個IP地址代替主機名會更有效率。因為可以避免一次DNS查詢。當使用一個低速的PPP與域名服務器連接時,Apache的域名解析會花費相當可觀的時間。
主機名不區(qū)分大小寫并且始終認為是錨定在DNS樹根上的,因此WWW.MyDomain.com和www.mydomain.com.(注意結(jié)尾點號)是完全等同的。
| 說明 | 應用于所代理資源的容器 |
|---|---|
| 語法 | <Proxy wildcard-url> ...</Proxy> |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
位于<Proxy>配置段中的指令僅作用于匹配的代理內(nèi)容。語句中可以使用shell風格的通配符。
比如說:下例僅允許yournetwork.example.com中的主機通過您的代理服務器訪問代理內(nèi)容:
<Proxy *>
Order Deny,Allow
Deny from all
Allow from yournetwork.example.com
</Proxy>
下例將在所有example.com的foo目錄下的文件通過代理服務器發(fā)送之前用INCLUDES過濾器進行處理:
<Proxy http://example.com/foo/*>
SetOutputFilter INCLUDES
</Proxy>
| 說明 | 確定如何處理不合法的應答頭 |
|---|---|
| 語法 | ProxyBadHeader IsError|Ignore|StartBody |
| 默認值 | ProxyBadHeader IsError |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
| 兼容性 | 僅在 Apache 2.0.44 及以后的版本中可用 |
ProxyBadHeader指令決定mod_proxy如何處理不合法的應答頭(比如丟失冒號(:))。參數(shù)的取值范圍如下:
IsErrorIgnoreStartBody| 說明 | 設置被代理屏蔽的語句、主機、域 |
|---|---|
| 語法 | ProxyBlock *|word|host|domain [word|host|domain] ... |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
ProxyBlock指令指定了一個由空格分隔的語句、主機和/或域的列表。對所有匹配這些語句、主機和/或域的HTTP、HTTPS、FTP文檔的請求都將被代理服務器阻斷。代理模塊亦會在啟動時嘗試確定列表中可能是主機名的項目對應的IP地址,并將其緩沖用于匹配測試。比如說:
ProxyBlock joes-garage.com some-host.co.uk rocky.wotsamattau.edu
通過IP地址,rocky.wotsamattau.edu將可能同樣被匹配。
請注意,wotsamattau已經(jīng)足夠匹配wotsamattau.edu了。
請注意
ProxyBlock *
將屏蔽對所有站點的連接。
| 說明 | 代理請求的默認域名 |
|---|---|
| 語法 | ProxyDomain Domain |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
此指令僅對位于局域網(wǎng)內(nèi)的Apache代理服務器有用。ProxyDomain指令指定了apache代理服務器歸屬的默認域。如果遇到了一個對沒有域名的主機的請求,就會根據(jù)配置自動生成一個加上了Domain的重定向應答。
ProxyRemote * http://firewall.mycompany.com:81
NoProxy .mycompany.com 192.168.112.0/21
ProxyDomain .mycompany.com
| 說明 | 覆蓋代理內(nèi)容的錯誤頁 |
|---|---|
| 語法 | ProxyErrorOverride On|Off |
| 默認值 | ProxyErrorOverride Off |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
| 兼容性 | 僅在 Apache 2.0 及以后的版本中可用 |
此指令用于反向代理設置中您想為最終用戶提供觀感一致的錯誤頁面時。它也同樣允許包含文件(通過mod_include的SSI)獲取錯誤號并作出相應的動作。(默認行為是顯示被代理的服務器的錯誤頁面,將此項目設為"On"將顯示SSI錯誤信息。)
| 說明 | 內(nèi)部緩沖區(qū)大小 |
|---|---|
| 語法 | ProxyIOBufferSize bytes |
| 默認值 | ProxyIOBufferSize 8192 |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
ProxyIOBufferSize指令用于調(diào)整內(nèi)部緩沖區(qū)(作為輸入輸出數(shù)據(jù)的暫存器)的大小。取值必須小于等于8192 。
在絕大多數(shù)情況下,不需要調(diào)整這個設置。
| 說明 | 應用于匹配正則表達式的代理資源的容器 |
|---|---|
| 語法 | <ProxyMatch regex> ...</ProxyMatch> |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
| 說明 | 轉(zhuǎn)發(fā)請求的最大代理數(shù)目 |
|---|---|
| 語法 | ProxyMaxForwards number |
| 默認值 | ProxyMaxForwards 10 |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
| 兼容性 | 僅在 Apache 2.0 及以后的版本中可用 |
ProxyMaxForwards指令指定了允許轉(zhuǎn)發(fā)請求的最大代理數(shù)目。這個設置是為了避免無限代理循環(huán)或DoS攻擊的發(fā)生。
ProxyMaxForwards 15
| 說明 | 將一個遠端服務器映射到本地服務器的URL空間中 |
|---|---|
| 語法 | ProxyPass [path] !|url [key=value key=value ...]] |
| 作用域 | server config, virtual host, directory |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
該指令允許你將一個遠端服務器映射到本地服務器的URL空間中,此時本地服務器并不充當代理角色,而是充當遠程服務器的一個鏡像。path是一個本地虛擬路徑名,url是一個指向遠程服務器的部分URL,并且不允許包含查詢字符串。
ProxyPass指令時,ProxyRequests指令通常應當被設為 off 。假設本地服務器地址是:http://example.com/ ,那么,
ProxyPass /mirror/foo/ http://backend.example.com/
將會導致對http://example.com/mirror/foo/bar的本地請求將會在內(nèi)部轉(zhuǎn)換為一個代理請求:http://backend.example.com/bar 。
"!"指令對于您不想對某個子目錄進行反向代理時很有用。比如說:
ProxyPass /mirror/foo/i !
ProxyPass /mirror/foo http://backend.example.com
將會代理除/mirror/foo/i之外的所有對backend.example.com下/mirror/foo的請求。
順序很重要,您需要把拒絕指令放置在普通ProxyPass指令之前。
As of Apache 2.1, the ability to use pooled connections to a backend
server is available. Using the key=value parameters it is
possible to tune this connection pooling. 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
ThreadsPerChild.
Setting min will determine how many connections will always
be open to the backend server. Upto the Soft Maximum or smax
number of connections will be created on demand. Any connections above
smax are subject to a time to live or ttl. Apache
will never create more than the Hard Maximum or max connections
to the backend server.
ProxyPass /example http://backend.example.com smax=5 max=20 ttl=120 retry=300
| Parameter | Default | Description |
|---|---|---|
| min | 0 | Minumum number of connections that will always be open to the backend server. |
| max | 1...n | 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 ThreadsPerChild.
Apache will never create more than the Hard Maximum connections
to the backend server. |
| smax | max | Upto the Soft Maximum
number of connections will be created on demand. Any connections above
smax are subject to a time to live or ttl.
|
| ttl | - | Time To Live for the inactive connections above the
smax connections in seconds. Apache will close all
connections that has not been used inside that time period.
|
| timeout | Timeout | 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 max
parameter.
|
| acquire | - | 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 SERVER_BUSY status to
the client.
|
| keepalive | Off | 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 KEEP_ALIVE
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 On.
|
| retry | 60 | 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. |
| loadfactor | 1 | Worker load factor. Used with BalancerMember. It is a number between 1 and 100 and defines the normalized weighted load applied to the worker. |
| route | - | Route of the worker when used inside load balancer. The route is a value appended to seesion id. |
| redirect | - | 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. |
If the Proxy directive scheme starts with the
balancer:// 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.
| Parameter | Default | Description |
|---|---|---|
| lbmethod | - | Balancer load-balance method. Select the load-balancing scheduler
method to use. Either byrequests, to perform weighted
request counting or bytraffic, to perform weighted
traffic byte count balancing. Default is byrequests.
|
| stickysession | - | Balancer sticky session name. The value is usually set to something
like JSESSIONID或PHPSESSIONID,
and it depends on the backend application server that support sessions.
|
| nofailover | Off | If set to On 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.
|
| timeout | 0 | Balancer timeout in seconds. If set this will be the maximum time to wait for a free worker. Default is not to wait. |
| maxattempts | 1 | Maximum number of failover attempts before giving up. |
ProxyPass /special-area http://special.example.com/ smax=5 max=10
ProxyPass / balancer://mycluster stickysession=jsessionid nofailover=On
<Proxy balancer://mycluster>
BalancerMember http://1.2.3.4:8009
BalancerMember http://1.2.3.5:8009 smax=10
# Less powerful server, don't send as many requests there
BalancerMember http://1.2.3.6:8009 smax=1 loadfactor=20
</Proxy>
When used inside a <Location> section, the first argument is omitted and the local
directory is obtained from the <Location>.
If you require a more flexible reverse-proxy configuration, see the
RewriteRule directive with the
[P] flag.
| 說明 | 調(diào)整由反向代理服務器發(fā)送的HTTP應答頭中的URL |
|---|---|
| 語法 | ProxyPassReverse [path] url |
| 作用域 | server config, virtual host, directory |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
此指令使Apache調(diào)整HTTP重定向應答中Location, Content-Location, URI頭里的URL。這樣可以避免在Apache作為反向代理使用時,后端服務器的HTTP重定向造成的繞過反向代理的問題。
只有明確指定的應答頭會被重寫,其它應答頭保持不變,并且HTML頁面中的URL也不會被修改。如果被代理的內(nèi)容包含絕對URL引用,那么將會繞過代理。有一個第三方模塊可以檢查并改寫HTML中的URL引用,該模塊就是Nick Kew編寫的mod_proxy_html。
path是本地虛擬路徑的名稱。url是遠端服務器的部分URL。與ProxyPass指令中的使用方法相同。
例如,假定本地服務器擁有地址http://example.com/ ,那么
ProxyPass /mirror/foo/ http://backend.example.com/
ProxyPassReverse /mirror/foo/ http://backend.example.com/
ProxyPassReverseCookieDomain backend.example.com public.example.com
ProxyPassReverseCookiePath / /mirror/foo/
不僅會把所有對http://example.com/mirror/foo/bar的請求直接轉(zhuǎn)換為對http://backend.example.com/bar的代理請求(由ProxyPass提供的功能),它還會重定向服務器backend.example.com的發(fā)送:當http://backend.example.com/bar被它重定向到http://backend.example.com/quux時,Apache會在轉(zhuǎn)交HTTP重定向應答到客戶端之前調(diào)整它為http://example.com/mirror/foo/quux 。注意:被用于構建URL的主機名與UseCanonicalName指令的設置有關。
注意,此ProxyPassReverse指令亦可與mod_rewrite的代理穿透特性(RewriteRule ... [P])聯(lián)用。因為它不依賴于相應的ProxyPass指令。
當在<Location>配置段中使用時,第一個參數(shù)會被忽略而采用由<Location>指令指定的本地目錄。
| 說明 | Adjusts the Domain string in Set-Cookie headers from a reverse- proxied server |
|---|---|
| 語法 | ProxyPassReverseCookieDomain internal-domain public-domain |
| 作用域 | server config, virtual host, directory |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
Usage is basically similar to
ProxyPassReverse, but instead of
rewriting headers that are a URL, this rewrites the domain
string in Set-Cookie headers.
| 說明 | Adjusts the Path string in Set-Cookie headers from a reverse- proxied server |
|---|---|
| 語法 | ProxyPassReverseCookiePath internal-path public-path |
| 作用域 | server config, virtual host, directory |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
Usage is basically similar to
ProxyPassReverse, but instead of
rewriting headers that are a URL, this rewrites the path
string in Set-Cookie headers.
| 說明 | 使用進入的HTTP請求頭來發(fā)送代理請求 |
|---|---|
| 語法 | ProxyPreserveHost On|Off |
| 默認值 | ProxyPreserveHost Off |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
| 兼容性 | 僅在 Apache 2.0.31 及以后的版本中可用 |
當啟用時,此選項將把傳入請求的"Host:"行傳遞給被代理的主機,而不是傳遞在ProxyPass中指定的主機名。
此選項一般為Off狀態(tài)。It is mostly
useful in special configurations like proxied mass name-based virtual
hosting, where the original Host header needs to be evaluated by the
backend server.
| 說明 | 代理HTTP和FTP連接的接收緩沖區(qū)大小(字節(jié)) |
|---|---|
| 語法 | ProxyReceiveBufferSize bytes |
| 默認值 | ProxyReceiveBufferSize 0 |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
ProxyReceiveBufferSize指令為增加的吞吐量指定了代理HTTP和FTP連接的(TCP/IP)網(wǎng)絡接收緩沖區(qū)。這個值必須大于512 ,或設置為"0"表示使用系統(tǒng)默認的緩沖大小。
ProxyReceiveBufferSize 2048
| 說明 | 用于處理某些特定請求的遠端代理 |
|---|---|
| 語法 | ProxyRemote match remote-server |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
此指令定義了此代理的遠端代理。match可以是遠端服務器支持的URL形式的名稱、或是遠端服務器使用的部分URL、或是代表服務器可以接受所有請求的"*"。remote-server是遠端服務器的部分URL。語法為:
remote-server = scheme://hostname[:port]
scheme是與遠端服務器交換信息時使用的協(xié)議;本模塊暫時只支持http協(xié)議。
ProxyRemote http://goodguys.com/ http://mirrorguys.com:8000
ProxyRemote * http://cleversite.com
ProxyRemote ftp http://ftpproxy.mydomain.com:8080
在最后一個例子中,代理會將封裝到另外一個HTTP代理請求中的FTP請求轉(zhuǎn)交到另外一個能處理它們的代理去。
此選項也支持反向代理配置:一個后端web服務器可以被嵌入到一個虛擬主機的URL空間中,哪怕它是由另一個代理轉(zhuǎn)交過來的。
| 說明 | 處理匹配正則表達式的請求的遠端代理 |
|---|---|
| 語法 | ProxyRemoteMatch regex remote-server |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
ProxyRemoteMatch與ProxyRemote令基本相同。除了第一個參數(shù)是由一個請求的URL變成了匹配的正則表達式。
| 說明 | 啟用正向(標準)代理請求 |
|---|---|
| 語法 | ProxyRequests On|Off |
| 默認值 | ProxyRequests Off |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
此指令將允許或禁止Apache作為正向代理服務器的功能(設置為Off并不會禁用ProxyPass指令)。
在一個典型的反向代理配置中,此可選項一般設置為Off。
為了能夠代理HTTP或FTP站點,mod_proxy_http或mod_proxy_ftp必須同時存在于服務器中。
在您沒有對服務器采取安全措施之前,請不要用ProxyRequests啟用您的代理。一個開放的代理服務器不僅對您的網(wǎng)絡有威脅,對整個因特網(wǎng)來說也同樣如此。
| 說明 | 代理請求的網(wǎng)絡超時 |
|---|---|
| 語法 | ProxyTimeout seconds |
| 默認值 | ProxyTimeout 300 |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
| 兼容性 | 僅在 Apache 2.0.31 及以后的版本中可用 |
此指令允許用戶對代理請求指定一個超時值。當你有一個很慢/錯誤多多的應用服務器經(jīng)常掛起,而您寧愿返回一個超時的失敗信息也不愿意繼續(xù)等待不知道多久的時候,這個功能是很有用的。
| 說明 | 控制代理對Via應答頭的使用 |
|---|---|
| 語法 | ProxyVia On|Off|Full|Block |
| 默認值 | ProxyVia Off |
| 作用域 | server config, virtual host |
| 狀態(tài) | 擴展(E) |
| 模塊 | mod_proxy |
此指令控制代理對"Via:"頭的使用。它的目的是控制位于代理服務器鏈中的代理請求的流向。參閱RFC 2616(HTTP/1.1)14.45小節(jié)以獲得關于"Via:"頭的解釋。
Off ,將不會采取特殊的處理。如果一個請求或應答包含"Via:"頭,將不進行任何修改而直接通過。On每個請求和應答都會對應當前主機得到一個"Via:"頭。Full ,每個產(chǎn)生的"Via:"頭中都會額外加入Apache服務器的版本,以"Via:"注釋域出現(xiàn)。Block ,每個代理請求中的所有"Via:"頭行都將被刪除。且不會產(chǎn)生新的"Via:"頭。