似乎NGINX不会将正确的HTTP协议传递给HHVM后端。
这里我做过的测试:
如果客户端发送HTTP / 1.1请求(非分块),NGINX会将其传递给HHVM后端,并且正确的响应将返回给客户端
(client) (server backend)
HTTP/1.1(non chunked) -> NGINX -> HHVM
|
v
(HTTP/1.1 200) <- NGINX <- (non chunked response)
如果客户端发送HTTP / 1.1请求(chuncked),则服务器会产生分块响应,但NGINX会触发此日志消息
upstream prematurely closed connection while reading response header from upstream, request: "POST /soap HTTP/1.1", upstream: "fastcgi://unix:/var/run/hhvm/sock:"
并返回502(错误网关)响应
(client) (server backend)
HTTP/1.1(chunked) -> NGINX -> HHVM
|
v
(HTTP/1.1 502) <- NGINX <- (chunked response)
为什么我使用分块响应从NGINX获得502?
hhvm / fastcgi / hhvm config有什么问题吗?
我仔细检查后端给出了正确的1/1响应:(
我的情景是:
NGINX:nginx/1.4.6 (Ubuntu)
HHVM: HipHop VM 3.6.1 (rel)
NGINX配置
server {
listen 80;
server_name xxxxx;
root /usr/share/nginx/web;
include hhvm.conf;
location / {
# try to serve file directly, fallback to rewrite
try_files $uri @rewriteapp;
}
location @rewriteapp {
# rewrite all to app.php
rewrite ^(.*)$ /app.php/$1 last;
}
location ~ ^/(app|app_dev|app_benchmark|app_logall|config)\.php(/|$) {
fastcgi_keep_conn on;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/hhvm/sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_read_timeout 240;
fastcgi_intercept_errors on;
include fastcgi_params;
}
}