我们有一个用TCL编写的应用程序,并使用wibble web server提供服务。它太可怕了,我想把nginx放在它的前面,这样我就可以将像/assets
这样的路径代理到像sprockets这样的资产服务器,将/help
代理到一个gollum服务器或者某些东西。
Wibble正在端口8080上运行,nginx正在端口80上运行,资产服务器正在端口9292上运行(从netstat -tulpna
输出如下所示):
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 27599/nginx
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 1536/tclsh8.6
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN 28941/rack
操作系统是Debian,因此/etc/nginx/sites-available/site
的配置文件链接在sites-enabled
(唯一的链接文件)目录中,并且nginx已重新启动。
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_read_timeout 120;
}
location /images {
proxy_pass http://127.0.0.1:9292/images/;
}
location /css {
proxy_pass http://127.0.0.1:9292/stylesheets/;
}
location /js {
proxy_pass http://127.0.0.1:9292/javascripts/;
}
}
问题是当我运行nginx并导航到端口80时,资产服务器的工作正常,但是wibble服务器从不回复导致nginx在upstream timed out
中发出/var/log/nginx/error.log
错误(服务器是192.168.3.127,我是192.168.3.90):
2014/07/07 12:07:29 [error] 27601#0: *1 upstream timed out (110: Connection timed out) while reading upstream, client: 127.0.0.1, server: localhost, request: "GET /nginx-status HTTP/1.1", upstream: "http://127.0.0.1:8080/nginx-status", host: "localhost"
2014/07/07 12:07:59 [error] 27601#0: *3 upstream timed out (110: Connection timed out) while reading upstream, client: 192.168.3.90, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8080/", host: "192.168.3.127"
2014/07/07 12:10:00 [error] 27601#0: *3 upstream timed out (110: Connection timed out) while reading upstream, client: 192.168.3.90, server: localhost, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "192.168.3.127"
2014/07/07 12:10:34 [error] 27601#0: *7 upstream timed out (110: Connection timed out) while reading upstream, client: 127.0.0.1, server: localhost, request: "GET /nginx-status HTTP/1.1", upstream: "http://127.0.0.1:8080/nginx-status", host: "localhost"
/var/log/nginx/access.log
中还有这些行:
192.168.3.90 - - [07/Jul/2014:12:06:19 +1200] "-" 400 0 "-" "-"
127.0.0.1 - - [07/Jul/2014:12:07:29 +1200] "GET /nginx-status HTTP/1.1" 404 0 "-" "Python-urllib/2.6"
192.168.3.90 - - [07/Jul/2014:12:07:59 +1200] "GET / HTTP/1.1" 200 31 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/34.0.1847.116 Chrome/34.0.1847.116 Safari/537.36"
Hangon,为什么要尝试获取这个不存在的/nginx-status
URI? wibble服务器在端口8080上运行。
如果我停止wibble服务器,并在同一个端口(8080)上加载一个简单的python服务器,那就很棒了!
我仍然可以通过转到http://192.168.3.127:8080
来访问wibble服务器,甚至可以在服务器上执行curl http://127.0.0.1:8080
打印出正确的HTML。
为什么wibble不回复nginx但回复浏览器并卷曲?
(我正在努力尝试输出日志)
答案 0 :(得分:1)
在轻松转储它的请求对象之后,我发现HTTP版本被设置为1.0,尽管这似乎不会影响curl -0
获取HTML。
将nginx升级到最新版本后,一切正常。