Configuring Varnish 4.0 will be much the same as in that tutorial. Like in that article, you’ll need to configure it to listen on port 80 and send requests to port 8080 where Nginx will listen. Varnish will pass everything on and Nginx will be responsible for routing the requests after that. If there is only one subdomain hosted on the server, then just make sure that server_name
is correctly set in your Nginx configuration.
Here’s a sample Nginx conf that you might use for a PHP site like WordPress:
server {
listen 8080 default_server;
root /var/www/html;
index index.php index.html index.htm;
server_name blog.example.com;
location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
Note it is listening on port 8080 and the server_name
is set.
If you were hosting more than one site on the same server and you only wanted one to be cached by Varnish, you’ll need to disable it for the subdomain in /etc/varnish/default.vcl
by using something like:
if (req.http.host == 'notcached.example.com') {
return (pass);
}

by Etel Sverdlov
Varnish is an HTTP accelerator and a useful tool for speeding up a server, especially during a times when there is high traffic to a site. It works by redirecting visitors to static pages whenever possible and only drawing on the server itself if there is a need for an active process. This tutorial covers installing wordpress on a LEMP stack (with nginx instead of apache), and then installing varnish.