<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>John McLear &#187; Varnish</title>
	<atom:link href="http://mclear.co.uk/category/varnish/feed/" rel="self" type="application/rss+xml" />
	<link>http://mclear.co.uk</link>
	<description>௵</description>
	<lastBuildDate>Fri, 03 May 2013 01:17:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://primaryblogger.co.uk/?v=3.5.1</generator>
		<item>
		<title>Varnish purge example</title>
		<link>http://mclear.co.uk/2011/12/15/varnish-purge-example/</link>
		<comments>http://mclear.co.uk/2011/12/15/varnish-purge-example/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 11:03:14 +0000</pubDate>
		<dc:creator>John McLear</dc:creator>
				<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://mclear.co.uk/?p=3986</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[<pre class="brush: plain; title: ; notranslate">
varnishadm -T 127.0.0.1:2000 purge.url &quot;/static/js/wall.js&quot;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mclear.co.uk/2011/12/15/varnish-purge-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress Varnish Cache Config / VCL</title>
		<link>http://mclear.co.uk/2011/10/05/wordpress-varnish-cache-config-vcl/</link>
		<comments>http://mclear.co.uk/2011/10/05/wordpress-varnish-cache-config-vcl/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 18:34:42 +0000</pubDate>
		<dc:creator>Admin Admin</dc:creator>
				<category><![CDATA[ICT]]></category>
		<category><![CDATA[Varnish]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mclear.co.uk/?p=3827</guid>
		<description><![CDATA[Note: I am now providing VCLs in separate branches on github as the Varnish VCL syntax has changed. Thanks to scoof for documenting the Varnish VCL changes. What is this for non-technical folks? WordPress sucks at delivering the same content over and over again, actually, I should rephrase that, wordpress rocks 99% of the time [...]]]></description>
				<content:encoded><![CDATA[<p>Note:  <a href="https://github.com/johnmclear/Wordpress-Varnish-VCL">I am now providing VCLs in separate branches on github as the Varnish VCL syntax has changed</a>.</p>
<p><a href="https://www.varnish-cache.org/docs/trunk/installation/upgrade.html">Thanks to scoof for documenting the Varnish VCL changes.</a></p>
<h2>What is this for non-technical folks?</h2>
<p>WordPress sucks at delivering the same content over and over again, actually, I should rephrase that, wordpress rocks 99% of the time but if you serve a page over and over again it will quickly exhaust your servers resource which will mean wordpress will go slow.  Varnish Cache speeds up WordPress by serving pages from memory instead of doinmagicg a bunch of hard work.</p>
<h2>Why should I use this VCL?</h2>
<p>I have done a number of different VCLs that can be used with varnish and wordpress but this is the final revision for now. It is designed for Varnish 2 but should work on 3 with no to very little modifications, I have tweaked this VCL over a few years and I&#8217;m finally happy with it.</p>
<p>Features:</p>
<ul>
<li>Supports multiple back-ends</li>
<li>Supports round-robin</li>
<li>Supports Purging using the <a title="Wordpress Varnish Plugin" href="http://wordpress.org/extend/plugins/wordpress-varnish/">Varnish WordPress plugin</a></li>
<li>Supports logged in users</li>
<li>Supports password protected pages</li>
<li>Supports Mobile devices</li>
<li>Provides long client side caching</li>
<li>Forwards the correct client IP to the web daemon.</li>
<li>Doesn&#8217;t cache 404s, 503, 500 etc.</li>
<li>Doesn&#8217;t cache wp-admin, login, preview, signup</li>
<li>Caches static objects such as images</li>
<li>Supports Multisite</li>
<li>Includes debug/log messages.</li>
<li>Really clean code, proper tabbing etc.</li>
</ul>
<h2>Requirements</h2>
<p><a href="https://www.varnish-cache.org/">Varnish</a>, <a href="http://wordpress.org">WordPress</a>, The <a title="Wordpress Varnish Plugin" href="http://wordpress.org/extend/plugins/wordpress-varnish/">Varnish WordPress plugin</a> installed and working, <a href="http://stderr.net/apache/rpaf/">mod_rpaf</a> installed in apache or an nginx equivalent.</p>
<h2>Why have I made this?</h2>
<p>I was going to make a VCL generator but then I remembered most people will use this VCL as a point of reference and I&#8217;m lazy, let&#8217;s face it, being lazy is the biggest factor in me backing out of making a generator. The varnish configs I have done before have been overly verbose for what they did and rewriting them and cleaning them up means this config is much easier to understand and modify. Adding logging means that you can easily use <a title="Varnishlog Cheat sheet" href="http://mclear.co.uk/2011/04/25/varnishlog-cheat-sheet/">varnishlog to debug</a> any problems you have.</p>
<h2>What isn&#8217;t included?</h2>
<p>I didn&#8217;t include Custom error messages in this VCL.  It&#8217;s not because I&#8217;m lazy, it&#8217;s because custom error messages put a lot of cruft into the VCL and if you want custom error messages you should see this article.</p>
<h2>Let me at it!</h2>
<p><a href="https://github.com/johnmclear/Wordpress-Varnish-VCL/tree/Varnish3">Varnish v3</a><br />
<a href="https://github.com/johnmclear/Wordpress-Varnish-VCL/blob/Varnish303/default.vcl">Varnish v3.03</a><br />
<strong>Which version of Varnish am I running?</strong></p>
<pre class="brush: plain; title: ; notranslate">varnishd -V</pre>
<h2>What do I need to change?</h2>
<p>Search and replace myFirstServer and mySecondServer with your server names adding new backends where required. Make sure new backends are added to the round-robin cluster and the purge list.</p>
<p>Once you are happy with your VCL save it in as /etc/varnish/default.vcl (remember to make a backup of your original file) and restart Varnish.  Any problems try to debug yourself but if you are stuck just give me a shout, I will be happy to help!</p>
]]></content:encoded>
			<wfw:commentRss>http://mclear.co.uk/2011/10/05/wordpress-varnish-cache-config-vcl/feed/</wfw:commentRss>
		<slash:comments>19</slash:comments>
		</item>
		<item>
		<title>How to install mod_rpaf Varnish WordPress Ubuntu</title>
		<link>http://mclear.co.uk/2011/09/09/how-to-install-mod_rpaf-varnish-wordpress-ubuntu/</link>
		<comments>http://mclear.co.uk/2011/09/09/how-to-install-mod_rpaf-varnish-wordpress-ubuntu/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 17:36:00 +0000</pubDate>
		<dc:creator>Admin Admin</dc:creator>
				<category><![CDATA[Varnish]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mclear.co.uk/?p=3755</guid>
		<description><![CDATA[And the geekiest title of the week goes to me&#8230; Add this line to your varnish VCL in sub_recv: Grab mod_rpaf: Install mod_rpaf Enable mod_rpaf: Your rpaf config (/etc/apache2/mods-enabled/rpaf.conf) should look awesome like this: Note: RPAFproxy_ips is the ips of your varnish cache servers. Varnish is awesome. Reload varnish and Apache the cool way. Test [...]]]></description>
				<content:encoded><![CDATA[<p>And the geekiest title of the week goes to me&#8230;</p>
<p>Add this line to your varnish VCL in sub_recv:</p>
<pre class="brush: plain; title: ; notranslate">set req.http.X-Forwarded-For = client.ip;</pre>
<p>Grab mod_rpaf:</p>
<pre class="brush: plain; title: ; notranslate">wget http://ftp.debian.org/debian/pool/main/liba/libapache2-mod-rpaf/libapache2-mod-rpaf_0.6-7_amd64.deb</pre>
<p>Install mod_rpaf</p>
<pre class="brush: plain; title: ; notranslate">dpkg -i libapache2-mod-rpaf_0.6-1_amd64.deb</pre>
<p>Enable mod_rpaf:</p>
<pre class="brush: plain; title: ; notranslate">a2enmod rpaf</pre>
<p>Your rpaf config (/etc/apache2/mods-enabled/rpaf.conf) should look awesome like this:</p>
<pre class="brush: plain; title: ; notranslate">
&lt;IfModule mod_rpaf.c&gt;
RPAFenable On
RPAFsethostname On
RPAFproxy_ips 123.123.123.123 10.0.0.2 127.0.0.1
RPAFheader HTTP_X_FORWARDED_FOR
&lt;/IfModule&gt;
</pre>
<p>Note: RPAFproxy_ips is the ips of your varnish cache servers.  Varnish is awesome.</p>
<p>Reload varnish and Apache the cool way.</p>
<pre class="brush: plain; title: ; notranslate">
/etc/init.d/varnish reload
/etc/init.d/apache reload
</pre>
<p>Test it by looking at your remote_addr variable:</p>
<pre class="brush: php; title: ; notranslate">
print_r($_SERVER);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mclear.co.uk/2011/09/09/how-to-install-mod_rpaf-varnish-wordpress-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WordPress mobile error: &#8220;the target server failed to respond&#8221;</title>
		<link>http://mclear.co.uk/2011/05/01/wordpress-mobile-error-the-target-server-failed-to-respond/</link>
		<comments>http://mclear.co.uk/2011/05/01/wordpress-mobile-error-the-target-server-failed-to-respond/#comments</comments>
		<pubDate>Sun, 01 May 2011 12:51:06 +0000</pubDate>
		<dc:creator>Admin Admin</dc:creator>
				<category><![CDATA[Varnish]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[wordpress multi User]]></category>
		<category><![CDATA[WPMU]]></category>

		<guid isPermaLink="false">http://mclear.co.uk/?p=2892</guid>
		<description><![CDATA[When joining a new mobile device to wordpress it looks like the first request is a GET request. My Varnish config only included support for POST requests to xmlrpc.php I updated my config to read: and it sorted it! Huraa]]></description>
				<content:encoded><![CDATA[<p>When joining a new mobile device to wordpress it looks like the first request is a GET request.</p>
<p>My Varnish config only included support for POST requests to xmlrpc.php</p>
<p>I updated my config to read:</p>
<pre class="brush: plain; title: ; notranslate">
// set backend, pipe, strip cookies from xmlrpc 
  if (req.request == &quot;POST&quot; &amp;&amp; req.url ~ &quot;xmlrpc.php&quot;) {remove req.http.cookie;set req.backend = mainserver;return(pipe);}
  if (req.request == &quot;GET&quot; &amp;&amp; req.url ~ &quot;xmlrpc.php&quot;) {remove req.http.cookie;set req.backend = mainserver;return(pipe);}
</pre>
<p>and it sorted it!  Huraa</p>
]]></content:encoded>
			<wfw:commentRss>http://mclear.co.uk/2011/05/01/wordpress-mobile-error-the-target-server-failed-to-respond/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Varnishlog cheat sheet</title>
		<link>http://mclear.co.uk/2011/04/25/varnishlog-cheat-sheet/</link>
		<comments>http://mclear.co.uk/2011/04/25/varnishlog-cheat-sheet/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 13:24:28 +0000</pubDate>
		<dc:creator>Admin Admin</dc:creator>
				<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://mclear.co.uk/?p=2853</guid>
		<description><![CDATA[BELOW IS VARNISH V3 Look at an incoming client request of a specific URL: Look at a a backend request of a specific URL: See requests for one specific Hostname: See the age of the cache objects for a specific hostname: BELOW IS VARNISH < V3 Look at an incoming client request of a specific [...]]]></description>
				<content:encoded><![CDATA[<div style="padding:10px;background:yellow;width:100%">BELOW IS VARNISH V3</div>
<p>Look at an incoming client request of a specific URL:</p>
<pre class="brush: plain; title: ; notranslate">varnishlog -c -m RxURL:&quot;readysetlearn/readysetlearn.htm&quot;</pre>
<p>Look at a a backend request of a specific URL:</p>
<pre class="brush: plain; title: ; notranslate">varnishlog -b -m TxURL:&quot;readysetlearn/readysetlearn.htm&quot;</pre>
<p>See requests for one specific Hostname:</p>
<pre class="brush: plain; title: ; notranslate">varnishlog -c -m RxHeader:&quot;Host: etherpad.org&quot;</pre>
<p>See the age of the cache objects for a specific hostname:</p>
<pre class="brush: plain; title: ; notranslate">varnishlog -c -m RxHeader:&quot;Host: etherpad.org&quot; | grep Age</pre>
<div style="padding:10px;background:yellow;width:100%">BELOW IS VARNISH < V3</div>
<p>Look at an incoming client request of a specific URL:</p>
<pre class="brush: plain; title: ; notranslate">varnishlog -c -o RxURL readysetlearn/readysetlearn.htm</pre>
<p>Look at a a backend request of a specific URL:</p>
<pre class="brush: plain; title: ; notranslate">varnishlog -b -o TxURL readysetlearn/readysetlearn.htm</pre>
<p>See requests for one specific Hostname:</p>
<pre class="brush: plain; title: ; notranslate">varnishlog -c -o RxHeader &quot;Host: etherpad.org&quot;</pre>
<p>See the age of the cache objects for a specific hostname:</p>
<pre class="brush: plain; title: ; notranslate">varnishlog -c -o RxHeader &quot;Host: etherpad.org&quot; | grep Age</pre>
<p>If an item has a high age it means that varnish is hitting the cache for it.</p>
<p>Thanks to Mithrandir from the #Varnish IRC channel for helping out and thanks to <a href="http://Tomnomnom.com">Tomnomnom</a> for V3 help!.</p>
]]></content:encoded>
			<wfw:commentRss>http://mclear.co.uk/2011/04/25/varnishlog-cheat-sheet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Mobile phone detection with Varnish &#8211; Quick getting started guide</title>
		<link>http://mclear.co.uk/2011/04/17/mobile-phone-detection-with-varnish-quick-getting-started-guide/</link>
		<comments>http://mclear.co.uk/2011/04/17/mobile-phone-detection-with-varnish-quick-getting-started-guide/#comments</comments>
		<pubDate>Sun, 17 Apr 2011 18:38:25 +0000</pubDate>
		<dc:creator>Admin Admin</dc:creator>
				<category><![CDATA[developer]]></category>
		<category><![CDATA[developing]]></category>
		<category><![CDATA[ICT]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[Varnish]]></category>

		<guid isPermaLink="false">http://mclear.co.uk/?p=2835</guid>
		<description><![CDATA[This is a quick reference guide, for a proper understanding of what you are doing use this guide. This solution is easier to implement and has less of a cpu overhead. Edit your /etc/varnish/mobile.vcl using this as a guide Test by looking in your server heads.. IE in PHP.. print_r ($_SERVER);]]></description>
				<content:encoded><![CDATA[<p>This is a quick reference guide, for a <a href="http://www.enrise.com/2011/02/mobile-device-detection-with-wurfl-and-varnish/">proper understanding of what you are doing use this guide</a>.  <a href="http://www.mobiledrupal.com/content/mobile-device-detection-varnish-0">This solution is easier to implement and has less of a cpu overhead.</a></p>
<pre class="brush: plain; title: ; notranslate">
yum install libxml2-devel
#OR
apt-get intall libxml2-dev
wget https://gist.github.com/raw/805710/9f34a18e528c20eff1c92672c6f1856ed849f5ea/wurfl.c
wget https://gist.github.com/raw/805710/b9272d8a1d32d29034574c88b81fc79eb050e21b/wurfl.h
gcc -c -o wurfl.o wurfl.c -I/usr/include/libxml2 -fPIC
gcc -shared -Wl,-soname,libwurfl.so.1 -o libwurfl.so.1.0.1 wurfl.o -lxml2
wget http://downloads.sourceforge.net/project/wurfl/WURFL/latest/wurfl-latest.zip
unzip wurfl-latest.zip
mv wurfl.xml /etc/wurfl.xml
cp libwurfl.so /usr/lib
ln -s /usr/lib/libwurfl.so /usr/lib64/libwurfl.so
</pre>
<p>Edit your /etc/varnish/mobile.vcl using <a href="https://gist.github.com/raw/805710/c414644257e76eb3a7b0b2f3574d93cf7cf9d462/default.vcl">this as a guide</a></p>
<pre class="brush: plain; title: ; notranslate">
/etc/init.d/varnish stop
/usr/sbin/varnishd -s malloc,32M -a 0.0.0.0:80 -f /etc/varnish/mobile.vcl   -p 'cc_command=exec cc -fpic -shared -Wl,-x -lwurfl -o %o %s'
</pre>
<p>Test by looking in your server heads..  IE in PHP..  print_r ($_SERVER);</p>
]]></content:encoded>
			<wfw:commentRss>http://mclear.co.uk/2011/04/17/mobile-phone-detection-with-varnish-quick-getting-started-guide/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Updated Varnish WordPress VCL</title>
		<link>http://mclear.co.uk/2011/02/27/updated-varnish-wordpress-vcl/</link>
		<comments>http://mclear.co.uk/2011/02/27/updated-varnish-wordpress-vcl/#comments</comments>
		<pubDate>Sun, 27 Feb 2011 22:56:42 +0000</pubDate>
		<dc:creator>johnyma22</dc:creator>
				<category><![CDATA[developer]]></category>
		<category><![CDATA[ICT]]></category>
		<category><![CDATA[Varnish]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://mclear.co.uk/?p=2611</guid>
		<description><![CDATA[THIS VARNISH CONFIG HAS BEEN UPDATED AND IS AVAILABLE HERE I have been tweaking a varnish vcl config for WordPress for quite some time and I wanted to share it..  Thanks to everyone(especially DocWilco)  in #varnish on Linpro IRC for helping Features: Load balancing Probing Does not cache wp-admin Puts all uploads/content requests onto one [...]]]></description>
				<content:encoded><![CDATA[<h2><a title="Wordpress Varnish VCL" href="http://mclear.co.uk/2011/10/05/wordpress-varnish-cache-config-vcl/">THIS VARNISH CONFIG HAS BEEN UPDATED AND IS AVAILABLE HERE</a></h2>
<p>I have been tweaking a varnish vcl config for WordPress for quite some time and I wanted to share it..  Thanks to everyone(especially DocWilco)  in #varnish on Linpro IRC for helping</p>
<p><strong>Features:</strong></p>
<ol>
<li>Load balancing</li>
<li>Probing</li>
<li>Does not cache wp-admin</li>
<li>Puts all uploads/content requests onto one server</li>
<li>Purging</li>
<li>Long timeout for file uploads</li>
<li>XML RPC support</li>
<li>Custom 404 and 500 message</li>
<li>Forwards user IP address for comments</li>
</ol>
<p>First of all.. Let&#8217;s define some backends..</p>
<pre class="brush: plain; title: ; notranslate">
// BACKEND CONFIGS
backend server1 {
  .host = &quot;server1.example.com&quot;;
  .port = &quot;8080&quot;;
  .probe = {
                .url = &quot;/&quot;;
                .interval = 5s;
                .timeout = 1 s;
                .window = 5;
                .threshold = 3;
  }
// we include time outs so uploads don't time out
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
}

backend server2 {
  .host = &quot;server2.example.com;
  .port = &quot;8080&quot;;
  .probe = {
                .url = &quot;/&quot;;
                .interval = 5s;
                .timeout = 1 s;
                .window = 5;
                .threshold = 3;
  }
// we include time outs so uploads don't time out
 .connect_timeout = 600s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 600s;
}

// define round-robin for backends
director cluster round-robin {
        {.backend = server1;}
        {.backend = server2;}
}

// set the servers wordpress can purge from
acl purge {
        &quot;server1.example.com&quot;;
        &quot;server2.example.com&quot;;
}

sub vcl_fetch {
 if (req.http.host ~ &quot;ourdomain.com&quot;
     || req.http.host ~ &quot;ourotherdomain.com&quot;
// don't cache wp-admin ever cause that's not cool
     &amp;&amp; req.url !~ &quot;wp-admin&quot;)
{
// we cache these domains for 8 hours unless they are purged.
        set beresp.ttl = 8h;
        set beresp.grace = 600s;
// don't cache 404 or 500 errors
        if (beresp.status == 404 || beresp.status &gt;= 500) {
                  set beresp.ttl = 0s;
        }
}
// tell all of the files to use server1
if (req.url ~ &quot;files&quot;) {set req.backend = server;set beresp.ttl = 8h;}
}

sub vcl_recv {
// Purge WordPress requests for purge
  if (req.request == &quot;PURGE&quot;) {
                if (!client.ip ~ purge) {
                        error 405 &quot;Not allowed.&quot;;
                }
                purge(&quot;req.url == &quot; req.url &quot; &amp;&amp; req.http.host == &quot; req.http.host);
                error 200 &quot;Purged.&quot;;
        }

// forward the client IP so comments show up properly
set req.http.X-Forwarded-For = client.ip;

// let server2 handle all feeds
    if (req.url ~ &quot;/feed/&quot;)
    {set req.backend = server2;}

// server1 must handle file uploads
    if (req.url ~ &quot;media-upload.php&quot;
    || req.url ~ &quot;file.php&quot;
    || req.url ~ &quot;async-upload.php&quot;)
    {set req.backend = server1;return(pass);}

// server1 can serve all files.
    if (req.url ~ &quot;/files/&quot;)
    {set req.backend = server1;}

// do not cache xmlrpc.php
    if (req.url ~ &quot;xmlrpc.php&quot;)
    {return(pass);}

// strip cookies from xmlrpc
    if (req.request == &quot;GET&quot; &amp;&amp; req.url ~ &quot;xmlrpc.php&quot;)
    remove req.http.cookie;return(pass);}

// caching these files is fine
if (req.http.Accept-Encoding) {
        if (req.url ~ &quot;\.(jpg|png|gif|gz|tgz|bz2|lzma|tbz)(\?.*|)$&quot;) {
            remove req.http.Accept-Encoding;
        } elsif (req.http.Accept-Encoding ~ &quot;gzip&quot;) {
            set req.http.Accept-Encoding = &quot;gzip&quot;;
        } elsif (req.http.Accept-Encoding ~ &quot;deflate&quot;) {
            set req.http.Accept-Encoding = &quot;deflate&quot;;
        } else {
            remove req.http.Accept-Encoding;
        }
}

// Remove cookies and query string for real static files
    if (req.url ~ &quot;^/[^?]+\.(jpeg|jpg|png|gif|ico|js|css|txt|gz|zip|lzma|bz2|tgz|tbz|html|htm)(\?.*|)$&quot;) {
       unset req.http.cookie;
       set req.url = regsub(req.url, &quot;\?.*$&quot;, &quot;&quot;);
    }

// Remove cookies from front page
    if (req.url ~ &quot;^/$&quot;) {
       unset req.http.cookie;
    }

// if the request is for our domain and not for wp-admin then load balance it to a server that is responding or send it to server1
if (req.http.host ~ &quot;ourdomain.com&quot;
    || req.http.host ~ &quot;ourotherdomain.com&quot;
    &amp;&amp; req.url !~ &quot;wp-admin&quot;)
{
        set req.http.X-Forwarded-For = client.ip;
        set req.backend = cluster;
        } else {
        set req.http.X-Forwarded-For = client.ip;
        set req.backend = server1;
}

// Custom error message
sub vcl_error {
if(obj.status == 404) {
        set obj.ttl = 0s;
  set obj.http.Content-Type = &quot;text/html; charset=utf-8&quot;;
    synthetic {&quot; &lt;!--?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?--&gt;

    &quot;} obj.status &quot; &quot; obj.response {&quot;
&lt;/pre&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;&lt;center&gt;
 &lt;img src=&quot;http://whatever.com/heavyload.jpg&quot; alt=&quot;&quot; width=&quot;600px&quot; /&gt;&lt;/center&gt;
&lt;h1&gt;This page is unavailable&lt;/h1&gt;
If you are seeing this page, either maintenance is being
performed or you are trying to access a file that doesn't exist. Please &lt;a href=&quot;http://whatever.com/contact.html&quot;&gt;contact us&lt;/a&gt; if you believe this is an error
&lt;h2&gt;Error &quot;} obj.status &quot; &quot; obj.response {&quot;&lt;/h2&gt;
&quot;} obj.response {&quot; on server &quot;} req.backend {&quot;
&lt;address&gt;&lt;a href=&quot;http://whatever.com/&quot;&gt;Us.&lt;/a&gt;&lt;/address&gt;&lt;/div&gt;
&lt;pre&gt;
  &quot;};
    return (deliver);
error 404 &quot;Not found&quot;;
 }
else
{
    set obj.http.Content-Type = &quot;text/html; charset=utf-8&quot;;
    synthetic {&quot; &lt;!--?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?--&gt;  
  
    &quot;} obj.status &quot; &quot; obj.response {&quot;
  

&lt;/pre&gt;
&lt;div style=&quot;background-color: white;&quot;&gt;&lt;center&gt;
 &lt;img src=&quot;http://whatever.com/heavyload.jpg&quot; alt=&quot;&quot; width=&quot;600px&quot; /&gt;&lt;/center&gt;
&lt;h1&gt;This website is unavailable&lt;/h1&gt;
If you are seeing this page, either maintenance is being
performed
 or something really bad has happened. Try returning in a few
minutes. If you still see this error in a few minutes please &lt;a href=&quot;http://whatever.com/contact.html&quot;&gt;contact us&lt;/a&gt;
&lt;h2&gt;Error &quot;} obj.status &quot; &quot; obj.response {&quot;&lt;/h2&gt;
&quot;} obj.response {&quot; on server &quot;} req.backend {&quot;
&lt;address&gt;&lt;a href=&quot;http://whatever.com/&quot;&gt;Us.&lt;/a&gt;&lt;/address&gt;&lt;/div&gt;
&lt;pre&gt;
  &quot;};
    return (deliver);
}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://mclear.co.uk/2011/02/27/updated-varnish-wordpress-vcl/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>WordPress and Varnish comment IPs</title>
		<link>http://mclear.co.uk/2010/12/03/wordpress-and-varnish-comment-ips/</link>
		<comments>http://mclear.co.uk/2010/12/03/wordpress-and-varnish-comment-ips/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 18:09:24 +0000</pubDate>
		<dc:creator>Admin Admin</dc:creator>
				<category><![CDATA[Primary Blogger]]></category>
		<category><![CDATA[Varnish]]></category>
		<category><![CDATA[WordPress]]></category>
		<category><![CDATA[WPMU]]></category>

		<guid isPermaLink="false">http://mclear.co.uk/?p=2164</guid>
		<description><![CDATA[If your WordPress install is behind Varnish you may have issues with Comments showing your Server IP. This will also cause problems with Spam as Akismet will not be able to check the source IP. In the vcl_recv part of your varnish config add this Then edit your WordPress wp-includes/comment.php and replace REMOTE_ADDR with HTTP_X_FORWARDED_FOR [...]]]></description>
				<content:encoded><![CDATA[<p>If your WordPress install is behind Varnish you may have issues with Comments showing your Server IP.  This will also cause problems with Spam as Akismet will not be able to check the source IP.</p>
<p>In the vcl_recv part of your varnish config add this</p>
<pre class="brush: plain; title: ; notranslate">
set req.http.X-Forwarded-For = client.ip;
</pre>
<p>Then edit your WordPress wp-includes/comment.php and replace REMOTE_ADDR with HTTP_X_FORWARDED_FOR<br />
Then edit your wp-content/plugins/akismet/akismet.php and replace REMOTE_ADDR with HTTP_X_FORWARDED_FOR</p>
<p>Restart varnish</p>
<pre class="brush: plain; title: ; notranslate">/etc/init.d/varnish restart</pre>
<p>Finished, test by commenting.</p>
<p>Note:  Users experiencing spam on PrimaryBlogger should now experience less spam and more accurate comment filtering.</p>
<p>If you are running Varnish 2.1.2 RPCXML will not work, you need to upgrade to 2.1.3..  You can find out your version by typing</p>
<pre class="brush: plain; title: ; notranslate">

varnishd -V

</pre>
]]></content:encoded>
			<wfw:commentRss>http://mclear.co.uk/2010/12/03/wordpress-and-varnish-comment-ips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
