在这种情况下,有一个服务器运行一些网站的清漆服务也configuration好。
现在,在另一台服务器上,我在LAMP环境+ W3TC Cache + APC中运行了2个wp多站点,现在我想configuration我的第一台服务器作为它的反向代理。
我想知道这是否会做到这一点:
acl whitelist { "localhost"; "127.0.0.1"; "ip server with varnish"; "ip wordpress server"; } sub vcl_recv { if ( ! client.ip ~ whitelist) { error 403 "Access denied"; }
在开始testing之前,由于我对Varnish的使用经验不多,我想听听你对于设置我的服务器VCL的ACL的意见,以允许来自外部服务器的请求
只要指出,Apache响应8080端口和清漆80。
默认/清漆
DAEMON_OPTS="-a ip-server-1:80 \ -T localhost:6082 \ -f /etc/varnish/main.vcl \ -S /etc/varnish/secret \ -s file,/var/lib/varnish/$INSTANCE/varnish_storage.bin,1G"
您添加的内容将确保除给定主机以外的任何人都无法通过其后面的服务器获得请求。
相反,您可以轻松地检查所请求的主机,并使清漆发送后端请求到正确的服务器像这个小例子;
backend server1 { .host = "127.0.0.1"; .port = "81"; } backend server2 { .host = "192.168.0.1"; .port = "80"; } sub vcl_recv { if (req.http.host ~ "www.domain1.com") { set req.backend = server1; } if (req.http.host ~ "www.domain2.com") { set req.backend = server2; } }