apache 的http代理出錯 502 Proxy Error

來源:互聯網
上載者:User

 

關鍵字: 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的例子:

  1. <VirtualHost *:
    80

      
  2.    JkMount /hr/servlet/* worker1    
  3.    JkMount /hr/*.jsp worker1    
  4.    JkMount /hr/*.
    do
     worker1 
      
  5.    ServerAdmin njgnini
    @163
    .com    
  6.    ServerName www.javaeye.com    
  7.    ServerAlias www.javaeye.com.cn    
  8.    RewriteEngine On    
  9.    RewriteRule ^/$ /hr/ [R,P]          
  10.       
  11.    SetEnv force-proxy
    -request-
    1.0
    .
    1
     
      
  12.    SetEnv proxy
    -nokeepalive 
    1
        
  13. </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了

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.