나는 Varnish 4.1을 사용하여 rubygems 리버스 프록시를 구현하려고합니다. 인트라넷 내부의 클라이언트는 일반적인 아웃 바운드 NAT를 가지고 있지 않으므로 내부적으로 모든 리디렉션을 따르기 위해 바니시가 필요하며 rubygems.org의 302와 CDN 서버의 응답을 모두 캐싱하는 것이 좋습니다. 여기 바니시로 내부적으로 리디렉션을하면
내 default.vcl입니다 :vcl 4.0;
import std;
backend default {
.host = "rubygems.org";
.port = "80";
}
sub vcl_recv {
std.syslog(180, "doing vcl_recv");
std.syslog(180, "req.url = " + req.url);
}
sub vcl_deliver {
std.syslog(180, "doing vcl_deliver");
std.syslog(180, "resp.status = " + resp.status);
if (resp.status == 302) {
set req.url = resp.http.Location;
std.syslog(180, "restarting with req.url = " + req.url);
return(restart);
}
}
sub vcl_backend_fetch {
std.syslog(180, "doing vcl_backend_fetch");
std.syslog(180, "bereq.retries = " + bereq.retries);
}
sub vcl_backend_error {
std.syslog(180, "doing vcl_backend_error");
}
I curl -i http://localhost/latest_specs.4.8.gz
는, 니스는 HTTP (503)를 던져 로그온하면 다음
varnishd[20384]: doing vcl_recv
varnishd[20384]: req.url = /latest_specs.4.8.gz
varnishd[20384]: doing vcl_backend_fetch
varnishd[20384]: bereq.retries = 0
varnishd[20384]: doing vcl_deliver
varnishd[20384]: resp.status = 302
varnishd[20384]: restarting with req.url = http://rubygems.global.ssl.fastly.net/latest_specs.4.8.gz
varnishd[20384]: doing vcl_recv
varnishd[20384]: req.url = http://rubygems.global.ssl.fastly.net/latest_specs.4.8.gz
varnishd[20384]: doing vcl_backend_fetch
varnishd[20384]: bereq.retries = 0
varnishd[20384]: doing vcl_deliver
varnishd[20384]: resp.status = 302
varnishd[20384]: restarting with req.url = http://rubygems.global.ssl.fastly.net/latest_specs.4.8.gz
varnishd[20384]: doing vcl_recv
varnishd[20384]: req.url = http://rubygems.global.ssl.fastly.net/latest_specs.4.8.gz
varnishd[20384]: doing vcl_backend_fetch
varnishd[20384]: bereq.retries = 0
varnishd[20384]: doing vcl_deliver
varnishd[20384]: resp.status = 302
varnishd[20384]: restarting with req.url = http://rubygems.global.ssl.fastly.net/latest_specs.4.8.gz
varnishd[20384]: doing vcl_recv
varnishd[20384]: req.url = http://rubygems.global.ssl.fastly.net/latest_specs.4.8.gz
varnishd[20384]: doing vcl_backend_fetch
varnishd[20384]: bereq.retries = 0
varnishd[20384]: doing vcl_deliver
varnishd[20384]: resp.status = 302
varnishd[20384]: restarting with req.url = http://rubygems.global.ssl.fastly.net/latest_specs.4.8.gz
그것은 후에도 새로운 URL을 요청하지 않는 것 req.url을 업데이트하고 요청을 다시 시작하십시오.