使用Varnish作为具有多个vhost的反向代理

时间:2016-06-15 11:02:32

标签: varnish

我只有一个公共IP地址,因此请使用Varnish作为多个服务器的反向代理。这是配置。

第一个物理服务器Varnish / Apache - 端口80,端口8080,IP地址10.0.0.40

第二个物理服务器3 Drupal Vhosts - 端口80,IP地址10.0.0.30

第3个物理服务器2个非Drupal Vhosts - 端口80,ip地址10.0.0.31

在/ etc / sysconfig / varnish中,

DAEMON_OPTS =" -a:80 \ -T localhost:6082 \ -f /etc/varnish/default.vcl \ -u varnish -g varnish \ -S / etc / varnish / secret \ -s file ,在/ var / lib中/清漆/ varnish_storage.bin,1G"

在默认的vcl中,

backend default {.host =" 127.0.0.1&#34 ;; .port =" 8080&#34 ;; }

反向代理工作正常,我可以通过检查http标头看到Varnish缓存工作。但是我不确定上面的配置是正确的还是最优的,特别是在默认的vcl文件中只有一个后端定义。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我建议采用以下方法:

NGINX > VARNISH > APACHE

  • Nginx :轻松处理SSL终止,您也可以使用它来缓存静态内容。据我所知, Nginx 在缓存静态内容方面优于 Varnish Varnish 不应该缓存静态内容。
  • 清漆:将接收来自 Nginx 的请求,并将其传递给 Apache
  • Apache :将充当负载均衡器,将请求发送到后端服务器(Drupal / Non-drupal)

检查以下资源:

1- HTTPS Everywhere With Nginx, Varnish And Apache

2- Simple load balancing with Apache

如果我的答案不够明确,请告诉我。