使用lighttpd + mod_proxy的间歇性错误

时间:2012-03-05 15:23:08

标签: lighttpd mod-proxy

我在嵌入式Linux设备上运行lighttpd v1.4.18。 Lighty正在侦听端口80并充当反向代理,以便将_http://192.168.0.1/foo1请求代理到_http://127.0.0.1:11111

### 1st appreach
proxy.server = ( "^/foo1" => ( "" => ( "host" => "127.0.0.1", "port" => 11111 )))

### 2nd approach
$HTTP["url"] =~ "^/foo1" { 
    proxy.server = ( "" => (( "host" => "127.0.0.1", "port" => 11111 ))) 
}

基本上,这很好用。但我确实在随机的基础上遇到404错误,尤其是在启动之后。如果后台服务“foo1”没有运行,我收到503错误消息,这是有道理的。但是因为我可以查询_http://192.168.0.1:11111并非如此......设备启动并运行“foo1”已准备好为传入请求提供服务。那么,为什么这些404错误会在第二种方法中出现?!

这是日志显示的内容......

2012-03-05 08:31:36: (request.c.294) fd: 6 request-len: 164 
POST /foo1 HTTP/1.1
Host: 192.168.0.1
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 450
Connection: close
SOAPAction: ""


2012-03-05 08:31:36: (response.c.205) -- splitting Request-URI 
2012-03-05 08:31:36: (response.c.206) Request-URI  :  /foo1
2012-03-05 08:31:36: (response.c.207) URI-scheme   :  http 
2012-03-05 08:31:36: (response.c.208) URI-authority:  192.168.0.1 
2012-03-05 08:31:36: (response.c.209) URI-path     :  /foo1
2012-03-05 08:31:36: (response.c.210) URI-query    :   
2012-03-05 08:31:36: (response.c.260) -- sanatising URI 
2012-03-05 08:31:36: (response.c.261) URI-path     :  /foo1
2012-03-05 08:31:36: (mod_proxy.c.1080) proxy - start 
2012-03-05 08:31:36: (response.c.375) -- before doc_root 
2012-03-05 08:31:36: (response.c.376) Doc-Root     : /var/www 
2012-03-05 08:31:36: (response.c.377) Rel-Path     : /foo1
2012-03-05 08:31:36: (response.c.378) Path         :  
2012-03-05 08:31:36: (response.c.426) -- after doc_root 
2012-03-05 08:31:36: (response.c.427) Doc-Root     : /var/www 
2012-03-05 08:31:36: (response.c.428) Rel-Path     : /foo1
2012-03-05 08:31:36: (response.c.429) Path         : /var/www/foo1
2012-03-05 08:31:36: (response.c.446) -- logical -> physical 
2012-03-05 08:31:36: (response.c.447) Doc-Root     : /var/www 
2012-03-05 08:31:36: (response.c.448) Rel-Path     : /foo1
2012-03-05 08:31:36: (response.c.449) Path         : /var/www/foo1
2012-03-05 08:31:36: (response.c.466) -- handling physical path 
2012-03-05 08:31:36: (response.c.467) Path         : /var/www/foo1
2012-03-05 08:31:36: (response.c.523) -- file not found 
2012-03-05 08:31:36: (response.c.524) Path         : /var/www/foo1
2012-03-05 08:31:36: (response.c.114) Response-Header: 
HTTP/1.1 404 Not Found
Connection: close
Content-Type: text/html
Content-Length: 345
Date: Mon, 05 Mar 2012 07:31:36 GMT
Server: lighttpd

这就是我期望看到的......

2012-03-05 08:42:43: (request.c.294) fd: 6 request-len: 164 
POST /foo1 HTTP/1.1
Host: 192.168.0.1
User-Agent: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 450
Connection: close
SOAPAction: ""


2012-03-05 08:42:43: (response.c.205) -- splitting Request-URI 
2012-03-05 08:42:43: (response.c.206) Request-URI  :  /foo1 
2012-03-05 08:42:43: (response.c.207) URI-scheme   :  http 
2012-03-05 08:42:43: (response.c.208) URI-authority:  192.168.0.1
2012-03-05 08:42:43: (response.c.209) URI-path     :  /foo1 
2012-03-05 08:42:43: (response.c.210) URI-query    :   
2012-03-05 08:42:43: (response.c.260) -- sanatising URI 
2012-03-05 08:42:43: (response.c.261) URI-path     :  /foo1 
2012-03-05 08:42:43: (mod_proxy.c.1080) proxy - start 
2012-03-05 08:42:43: (mod_proxy.c.1116) proxy - ext found 
2012-03-05 08:42:43: (mod_proxy.c.1159) proxy - used fair balancing 
2012-03-05 08:42:43: (mod_proxy.c.1240) proxy - found a host 127.0.0.1 11111 
2012-03-05 08:42:43: (response.c.375) -- before doc_root 
2012-03-05 08:42:43: (response.c.376) Doc-Root     : /var/www 
2012-03-05 08:42:43: (response.c.377) Rel-Path     : /foo1 
2012-03-05 08:42:43: (response.c.378) Path         :  
2012-03-05 08:42:43: (response.c.426) -- after doc_root 
2012-03-05 08:42:43: (response.c.427) Doc-Root     : /var/www 
2012-03-05 08:42:43: (response.c.428) Rel-Path     : /foo1 
2012-03-05 08:42:43: (response.c.429) Path         : /var/www/foo1 
2012-03-05 08:42:43: (response.c.446) -- logical -> physical 
2012-03-05 08:42:43: (response.c.447) Doc-Root     : /var/www 
2012-03-05 08:42:43: (response.c.448) Rel-Path     : /foo1 
2012-03-05 08:42:43: (response.c.449) Path         : /var/www/foo1 
2012-03-05 08:42:43: (mod_proxy.c.377) connect delayed: 7 
2012-03-05 08:42:43: (mod_proxy.c.994) proxy: fdevent-out 1 
2012-03-05 08:42:43: (mod_proxy.c.805) proxy - connect - delayed success 
2012-03-05 08:42:43: (mod_proxy.c.961) proxy: fdevent-in 4 
2012-03-05 08:42:43: (mod_proxy.c.645) proxy - have to read: 607 
2012-03-05 08:42:43: (mod_proxy.c.961) proxy: fdevent-in 4 
2012-03-05 08:42:43: (mod_proxy.c.645) proxy - have to read: 0 
2012-03-05 08:42:43: (response.c.114) Response-Header: 
HTTP/1.1 200 OK
Connection: close
Server: gSOAP/2.7
Content-Type: text/xml; charset=utf-8
Content-Length: 490
Date: Mon, 05 Mar 2012 07:42:43 GMT

较新的版本会修复该问题吗?还有其他建议吗?

非常感谢提前!

1 个答案:

答案 0 :(得分:0)

lighttpd中的mod_proxy有很多错误并且不是那么可靠(上下游速度的大不匹配之类的东西会因为缺乏流量控制而绊倒它)。话虽如此,你应该考虑使用更新版本的lighttpd而不是1.4.18 - 版本1.4.30是最新的。但是,即使是最新版本也可能会在您的特定网络上发现。

由于您处于嵌入式环境中,因此可能无法升级lighttpd,因此您还可以尝试重复上游地址等一些技巧,以便mod_proxy在认为存在错误时将“失败”到同一服务器。您还可以使用值proxy.balancefair, round-robin的{​​{1}}配置进行游戏 - 有时可以提供帮助。