2013-02-12 160 views
11

我有什麼和作品所有的ProxyPass映射:設置超時在Apache服務器的mod_proxy指令

我使用apache httpd的2.2的代理請求。我有多個的ProxyPass映射:

ProxyRequests On 
<Proxy *> 
AddDefaultCharset off 
    Order deny,allow 
    Allow from all 
</Proxy> 
ProxyPreserveHost Off 

ProxyPass /a http://some_ip/ 
ProxyPassReverse /a http://some_ip/ 

ProxyPass /b http://some_other_ip/ 
ProxyPassReverse /b http://some_other_ip/ 

... 

這種運作良好。

我想要什麼:

我的一些要求正在較長,所以他們超時給我一個代理錯誤 - 原因:錯誤從遠程服務器閱讀。

我想爲我的所有請求設置timeout。我可以在不需要爲每個ProxyPass映射添加timeout=... KeepAlive=On的情況下執行此操作嗎?

目前,我有這樣的:

ProxyPass /a http://some_ip/ timeout=1200 KeepAlive=On 
ProxyPassReverse /a http://some_ip/ 

ProxyPass /b http://some_other_ip/ timeout=1200 KeepAlive=On 
ProxyPassReverse /b http://some_other_ip/ 

... and i do this for all my ProxyPass mappings 

我可以告訴Apache以某種方式加入timeoutKeepAlive參數的所有映射?提前致謝。

+0

題外話。嘗試serverfault.com。 – EJP 2013-02-12 09:26:03

+1

我同意你在ServerFault中的更好,但有Apache和mod_proxy相關標籤,是不是?我的問題針對的是Apache 2.2 Server的mod_proxy指令設置。 – 2013-02-12 10:03:08

+3

我知道,謝謝你。我管理,但我自己找到一個解決方案,我在這裏添加它,也許有人認爲它有用。 – 2013-02-12 12:20:52

回答

25

我設法找到了我自己的解決方案。您可以使用mod_proxy直接ProxyTimeout指令設置的超時:

ProxyRequests On 
<Proxy *> 
    AddDefaultCharset off 
    Order deny,allow 
    Allow from all 
</Proxy> 
ProxyPreserveHost Off 

ProxyTimeout 1200 
+0

ProxyPreserveHost的用途是什麼?要設置超時ProxyTimeout指令是不夠的!我們是否必須指定所有這些行來設置ProxyTimeout? – ArunRaj 2015-02-19 03:20:52

+0

這些行添加在哪裏? – user230910 2017-05-06 07:04:25