我有nginx作为前端反向代理+清漆缓存+ web应用程序后端设置,请求正在通过nginx - >清漆 - >后端,我可以看到所有方面的日志,但它会为所有请求返回空白200响应。
我的/etc/default/varnish.vcl
vcl 4.0;
backend jira {
.host = "127.0.0.1";
.port = "27988";
}
sub vcl_recv {
set req.backend_hint = jira;
if (req.url ~ "\.(png|gif|jpg|swf|css|js)$") {
unset req.http.Cookie;
return (pipe);
} else {
return (pass);
}
}
sub vcl_backend_response {
if (bereq.url ~ "\.(css|js|jpg|jpeg|gif|png|ico)$") {
unset beresp.http.set-cookie;
set beresp.ttl = 30m;
#Set Grace Time to one hour
set beresp.grace = 1h;
}
}
我的nginx conf
server {
listen 80;
server_name jira.lan.mysite.com;
location / {
proxy_pass http://127.0.0.1:6081/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
80 - nginx port
6081 - varnish port
27988 - backend server(jira) port
请求jira.lan.fongwell.com
首先转到nginx,然后是varnish,然后是后端,如果不是静态资源,但都返回空200响应。
如果我绕过nginx去清漆,例如。 192.168.0.119:6081
,其中6081
是清漆端口,然后工作正常!
浏览器上返回的http响应标头
Accept-Ranges bytes
Age 0
Cache-Control no-cache, no-store, must-revalidate
Connection keep-alive
Content-Encoding gzip
Content-Length 0
Content-Type text/html;charset=UTF-8
Date Fri, 11 Dec 2015 01:50:57 GMT
Expires Thu, 01 Jan 1970 00:00:00 GMT
Pragma no-cache
Server nginx/1.4.6 (Ubuntu)
Set-Cookie JSESSIONID=C49D71942379289A803041B4257E6328; Path=/; HttpOnly
Vary User-Agent
Via 1.1 varnish-v4
X-AREQUESTID 110x16852x1
X-ASEN SEN-L4572887
X-AUSERNAME anonymous
X-Varnish 32779
x-content-type-options nosniff
我的设置有什么问题?感谢
答案 0 :(得分:4)
你试过这个吗?
do.call("rbind", lapply(split(dat, dat$ACCOUNT), function(x) {
x$NewAmount <- sapply(1:nrow(x), function(r) {
d <- (x$POSTING_DT[r] - x$POSTING_DT)
idx <- (x$ACCOUNT == x$ACCOUNT[r]) & (d >= 0) & (d <= 365)
idx[r] <- FALSE
with(x, sum(WA[idx] * Amount[idx]) / sum(Amount[idx]))
}, USE.NAMES=FALSE)
x
}))
我有一个类似的问题,问题是nginx使用http / 1.0协议作为反向代理,看起来它无法处理编码很好的块内容。