I'd like more details. To start, here's what I have in my settings.php:
/**
* Varnish settings
*/
$conf['cache_backends'][] = 'sites/all/modules/varnish/varnish.cache.inc';
$conf['cache_class_cache_page'] = 'VarnishCache';
$conf['reverse_proxy'] = true;
$conf['cache'] = 1;
$conf['cache_lifetime'] = 0;
$conf['page_cache_maximum_age'] = 21600;
$conf['reverse_proxy_header'] = 'HTTP_X_FORWARDED_FOR';
//$conf['page_cache_invoke_hooks'] = false;
$conf['reverse_proxy_addresses'] = array('127.0.0.1');
$conf['omit_vary_cookie'] = true;
$conf['page_cache_invoke_hooks'] = FALSE;
All of that might not be necessary, like $conf['page_cache_invoke_hooks'] = FALSE - but it's working for me
First, did you set Varnish to port 80 and Apache to port 8080? First try to access the site via http://example.com:8080 to see if Apache is still serving pages. Another way to check for servers working is by opening terminal via ssh and typing 'netstat -anp | grep httpd'. Here is my output:
netstat -anp | grep httpd
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 324/httpd
netstat -anp | grep varnish
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 24841/varnishd
tcp 0 0 127.0.0.1:6082 0.0.0.0:* LISTEN 24840/varnishd
You can see that apache (httpd) is working on :8080 and varnishd (d for daemon i.e. service) is running on :80 and :6082 where :80 is varnish and :6082 is its backend.
If you CAN see site on :8080 and you have varnish running on :80 and :6082 you should go to the varnish drupal config page via http://example.com:8080/admin/config/development/varnish
From there you should select the correct Varnish version set, the Varnish Control Terminal set to 127.0.0.1:6082, and your Varnish Control Key set. You can find this by seeing the output of the secret file. In CentOS you can do this by: cat /etc/varnish/secret
- this will give you a 30ish char long string to input. At the bottom of this settings page you will find "Status: Varnish Running" hopefully.
If you have all of this working and still can't get the site to show, it will be giving you an output noting Varnish and a Guru Meditation. This shows you that varnish is indeed running but just isn't configured correctly, most likely in your .vcl file. If no guru meditation and site not working, you probably haven't set the sysconfig correctly. Edit - again CentOS - /etc/sysconfig/varnish
using vi or nano. I have the following uncommented:
// using Alternative 2, Configuration with VCL
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s file,/var/lib/varnish/varnish_storage.bin,1G \
Check that the .vcl file is correctly referenced and that the port (:6082) is the same as what you found with netstat above.
Finally, if you are getting the Varnish Guru Meditation the .vcl is the issue. In this case here's some of what I have for the .vcl:
BEGINNING OF FILE ->
backend default {
.host = "127.0.0.1";
.port = "8080";
.connect_timeout = 600s;
.first_byte_timeout = 600s;
.between_bytes_timeout = 600s;
}
sub vcl_recv {
//TRY THIS AT BEGINNING ->
return(pass)
..
}
The return(pass)
will pass EVERYTHING and thus Varnish won't actually be caching anything, but you can use for diagnosis. Remember after changing anything varnish related you need to restart varnish by: service varnish restart
- if you .vcl has any errors it won't restart.