I've consulted several different varnish how-to documents and am still getting a hitrate of 0 in varnishstat. In my ports.conf, I have...
NameVirtualHost *:80
NameVirtualHost *:8000
NameVirtualHost *:443
Listen 80
Listen 8000
...and in apache2.conf I have this config for the site...
<VirtualHost *:8000>
DocumentRoot /var/www/solr/public_html
ServerName solr.ryan.com
</VirtualHost>
...and in the varnish file I have...
DAEMON_OPTS="-a :80 \
-T localhost:6082 \
-f /etc/varnish/default.vcl \
-S /etc/varnish/secret \
-s malloc,256m"
...and in my default.vcl I have this vcl_deliver...
sub vcl_deliver {
if (obj.hits > 0) {
set resp.http.X-Varnish-Cache = "HIT";
}
else {
set resp.http.X-Varnish-Cache = "MISS";
}
}
I am accessing the site at http://solr.ryan.com:8000. If I curl the site I get...
ryan@ryan-HP-ProBook-4530s:/var/www/solr/public_html/sites$ curl -s -D - solr.ryan.com:8000 -o /dev/null
HTTP/1.1 200 OK
Date: Wed, 27 Aug 2014 17:07:13 GMT
Server: Apache/2.2.22 (Ubuntu)
X-Powered-By: PHP/5.3.10-1ubuntu3.13
X-Drupal-Cache: HIT
Etag: "1409156602-0"
Content-Language: en
X-Generator: Drupal 7 (http://drupal.org)
Cache-Control: public, max-age=21600
Last-Modified: Wed, 27 Aug 2014 16:23:22 +0000
Expires: Sun, 19 Nov 1978 05:00:00 GMT
Vary: Cookie,Accept-Encoding
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
As you can see, there is no varnish header. This is a Drupal site, but at the moment I don't think it's a Drupal problem. It seems more likely it is a basic problem in my apache config?
You need to access solr.ryan.com on port 80. Right now you are directly accessing Apache Server.
To get Varnish into picture, you need to hit to Varnish which looks to be running on port 80 with configuration you mentioned above.
Also you need to remove listening to port 80 in Apache which is conflicting with Varnish.