0
votes

I have only one public ip address so use Varnish as a reverse proxy for multiple servers. Here is the configuration.

1st physical server Varnish/Apache - port 80, port 8080, ip address 10.0.0.40

2nd physical server 3 Drupal Vhosts - port 80, ip address 10.0.0.30

3rd physical server 2 Non Drupal Vhosts - port 80, ip address 10.0.0.31

In /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/varnish_storage.bin,1G"

In default vcl,

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

Reverse proxy is working ok and I can see Varnish cache working by checking http header. However I am not sure above configuration is correct or optimal, especially only one backend definition on default vcl file. Any advice?

1

1 Answers

0
votes

I suggest the following approach:

NGINX > VARNISH > APACHE

  • Nginx: to handle SSL termination easily and also you can use it to cache the static content. As far as I know that Nginx is better than Varnish in caching the static content also Varnish is not supposed to cache the static content.
  • Varnish: will receive requests from Nginx and pass it to Apache.
  • Apache: will act as a load balancer which will send the requests to the backend servers (Drupal/Non-drupal)

Check the following resources:

1- HTTPS Everywhere With Nginx, Varnish And Apache

2- Simple load balancing with Apache

If my answer is not clear enough let me know.