關鍵字: apache
502
proxy
error
前不久剛部署好的網站,忽然訪問報錯提示錯誤 引用Http 502
Proxy
Error
The proxy
server received an invalid response from an upstream
server.
The proxy
server could not handle the
request GET /.
Reason: Error
reading from remote
server
看了半天也沒看出個所以然來, 剛剛還好好的呢!過了一會網站又能開啟了....
查看了一下apache
的access_log。發現 引用.....Get /
HTTP/1.0....
這是ie5.5以下的版本訪問過。所以又找來台ie5.5(挺難整,這年頭這玩意少了!!)訪問了一下,然後出錯。在用別的機器訪問錯誤還有。在重新整理了一會又好了!
就這個問題Google了一下發現是mod_proxy的事,又G了一下他的文檔
http://httpd.apache
.org/docs/2.3/mod/mod_proxy.html
找到了這一段話
引用For circumstances where mod_proxy is sending requests to an
origin server that doesn't properly implement keepalives or HTTP/1.1, there are
two environment variables that can force the request to use HTTP/1.0 with no
keepalive. These are set via the SetEnv directive.
These are the force-proxy
-request-1.0 and proxy
-nokeepalive notes.
譯了一下大概是這意思(不是我譯的) 引用當mod_proxy向一個沒有正確實現持久串連(KeepAlive)或HTTP/1.1的原始伺服器發送請求的時候,可以通過設定兩個環境變數來發送不帶持久串連(KeepAlive)的HTTP/1.0請求。這兩個變數是通過SetEnv指令設定的。
以下是force-proxy
-request-1.0和proxy
-nokeepalive的例子:
- <VirtualHost *:
80
>
- JkMount /hr/servlet/* worker1
- JkMount /hr/*.jsp worker1
- JkMount /hr/*.
do
worker1
- ServerAdmin njgnini
@163
.com
- ServerName www.javaeye.com
- ServerAlias www.javaeye.com.cn
- RewriteEngine On
- RewriteRule ^/$ /hr/ [R,P]
-
- SetEnv force-proxy
-request-
1.0
.
1
- SetEnv proxy
-nokeepalive
1
- </VirtualHost>
<VirtualHost *:80> JkMount /hr/servlet/* worker1 JkMount /hr/*.jsp worker1 JkMount /hr/*.do worker1 ServerAdmin njgnini@163.com ServerName www.javaeye.com ServerAlias www.javaeye.com.cn RewriteEngine On RewriteRule ^/$ /hr/ [R,P] SetEnv force-proxy-request-1.0.1 SetEnv proxy-nokeepalive 1 </VirtualHost>
重啟apache
,在拿ie5.5訪問O了