<?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>install varnish &#8211; lifeLinux: Linux Tips, Hacks, Tutorials, Ebooks</title>
	<atom:link href="http://lifelinux.com/tag/install-varnish/feed/" rel="self" type="application/rss+xml" />
	<link>http://lifelinux.com</link>
	<description>All About Linux !</description>
	<lastBuildDate>Wed, 09 Oct 2013 07:57:42 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.5.3</generator>
	<item>
		<title>How to Install Varnish 3 On CentOS</title>
		<link>http://lifelinux.com/how-to-install-varnish-3-on-centos/</link>
					<comments>http://lifelinux.com/how-to-install-varnish-3-on-centos/#comments</comments>
		
		<dc:creator><![CDATA[lifeLinux]]></dc:creator>
		<pubDate>Thu, 03 Nov 2011 16:51:51 +0000</pubDate>
				<category><![CDATA[WebServer]]></category>
		<category><![CDATA[cache for wordpress]]></category>
		<category><![CDATA[configure varnish]]></category>
		<category><![CDATA[configure varnish for wordpress]]></category>
		<category><![CDATA[install reverse proxy]]></category>
		<category><![CDATA[install varnihs cache for wordpress]]></category>
		<category><![CDATA[install varnish]]></category>
		<category><![CDATA[setup varnish]]></category>
		<category><![CDATA[varnish cache]]></category>
		<category><![CDATA[varnish cache server]]></category>
		<category><![CDATA[varnish vs squid]]></category>
		<category><![CDATA[varnish with wordpress]]></category>
		<guid isPermaLink="false">http://www.lifelinux.com/?p=1242</guid>

					<description><![CDATA[<p>Varnish is an HTTP accelerator designed for content-heavy dynamic web sites. In contrast to other HTTP accelerators, such as Squid, which began life as a client-side cache, or Apache and nginx, which are primarily origin servers, Varnish was designed from the ground up as an HTTP accelerator. Installation on CentOS / RedHat Varnish is distributed [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://lifelinux.com/how-to-install-varnish-3-on-centos/">How to Install Varnish 3 On CentOS</a> appeared first on <a rel="nofollow" href="http://lifelinux.com">lifeLinux: Linux Tips, Hacks, Tutorials, Ebooks</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p></p><p><strong>Varnish</strong> is an HTTP accelerator designed for content-heavy dynamic web sites. In contrast to other HTTP accelerators, such as Squid, which began life as a client-side cache, or Apache and nginx, which are primarily origin servers, Varnish was designed from the ground up as an HTTP accelerator.<br />
<span id="more-1242"></span></p>
<h2>Installation on CentOS / RedHat</h2>
<p>Varnish is distributed in the EPEL (Extra Packages for Enterprise Linux) package repositories. To use the varnish-cache.org repository, login as root and type the following command</p>
<pre>
# rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm
</pre>
<p>And type the following command to install Varnish</p>
<pre>
# yum install varnish
</pre>
<p>If you get the following error</p>
<pre>
Resolving Dependencies
--> Running transaction check
---> Package varnish.x86_64 0:3.0.1-1.el5 set to be updated
--> Processing Dependency: varnish-libs = 3.0.1-1.el5 for package: varnish
--> Processing Dependency: libedit.so.0()(64bit) for package: varnish
--> Running transaction check
---> Package varnish.x86_64 0:3.0.1-1.el5 set to be updated
--> Processing Dependency: libedit.so.0()(64bit) for package: varnish
---> Package varnish-libs.x86_64 0:3.0.1-1.el5 set to be updated
--> Finished Dependency Resolution
varnish-3.0.1-1.el5.x86_64 from varnish-3.0 has depsolving problems
  --> Missing Dependency: libedit.so.0()(64bit) is needed by package varnish-3.0.1-1.el5.x86_64 (varnish-3.0)
Error: Missing Dependency: libedit.so.0()(64bit) is needed by package varnish-3.0.1-1.el5.x86_64 (varnish-3.0)
 You could try using --skip-broken to work around the problem
 You could try running: package-cleanup --problems
                        package-cleanup --dupes
                        rpm -Va --nofiles --nodigest
</pre>
<p>Type the following command to fix it</p>
<pre>
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
</pre>
<p>To start Varnish for the first time, type the following command</p>
<pre>
# /etc/init.d/varnish start
</pre>
<p>If you want to run Nginx by default when the system boots, type the following command</p>
<pre>
# chkconfig --level 345 varnish on
</pre>
<h2>Configure Varnish cache for WordPress</h2>
<p>Con­fig­ure Var­nish con­fig file (/etc/varnish/default.vcl.) with the following content</p>
<pre>
# Back-End
backend default {
	.host = "127.0.0.1";
  	.port = "80";
  	.connect_timeout = 60s;
  	.first_byte_timeout = 10s;
  	.between_bytes_timeout = 10s;
}

# Custom
sub vcl_recv {
	remove req.http.X-Forwarded-For; 
	set req.http.X-Forwarded-For = client.ip;

	if (req.url ~ "^/wp-(login|admin)") {
		return (pipe);
	}
	
	if (req.http.Cookie ~"(wp-postpass|wordpress_logged_in|comment_author_)") {
		return (pipe);
	}

	if (req.request == "POST") {
		return (pass);
	}

	if (req.http.Cache-Control ~ "no-cache") {
		return (pass);
	}

	if (req.http.Authorization) {
		return (pass);
	}

	if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|htm|html)$") {
		unset req.http.Cookie;
		unset req.http.Accept-Encoding;
		unset req.http.Vary;
		return (lookup);
	}

	if (req.http.Accept-Encoding) {
		if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
			remove req.http.Accept-Encoding;
		} elsif (req.http.Accept-Encoding ~ "gzip") {
			set req.http.Accept-Encoding = "gzip";
		} elsif (req.http.Accept-Encoding ~ "deflate") {
			set req.http.Accept-Encoding = "deflate";
		} else {
			remove req.http.Accept-Encoding;
		}
	}

	if (req.backend.healthy) {
		set req.grace = 30s;
	} else {
		set req.grace = 1h;
	}

	unset req.http.Cookie;
	unset req.http.Vary;
	return (lookup);
}

sub vcl_fetch {
	set beresp.grace = 1h;
	unset beresp.http.set-cookie;
	if (req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|htm|html)$") {
		set beresp.ttl = 24h;
	} else {
		set beresp.ttl = 5m;
	}
	return (deliver);
}

sub vcl_deliver {
	if(obj.hits > 0) {
		set resp.http.X-Cache = "HIT";
	} else {
		set resp.http.X-Cache = "MISS";
	}
	set resp.http.Cache-Control = "private";
	set resp.http.Pragma = "private";
	remove resp.http.X-Varnish;
	remove resp.http.Via;
	remove resp.http.Age;
	remove resp.http.Server;
	remove resp.http.X-Powered-By;
}

sub vcl_pipe {
	set bereq.http.connection = "close";
}
</pre>
<p>By default, Varnish is listening on port 6081. To Varnish can handle traffic of website on port 80, you can using iptables to redirect traffic from port 80 to port 6081, type the following command</p>
<pre>
# iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 6081
</pre>
<p>And type the following command to save iptables rules</p>
<pre>
# /etc/init.d/iptables save
</pre>
<g:plusone href="http://lifelinux.com/how-to-install-varnish-3-on-centos/" size="standard"  annotation="none"   ></g:plusone><p>The post <a rel="nofollow" href="http://lifelinux.com/how-to-install-varnish-3-on-centos/">How to Install Varnish 3 On CentOS</a> appeared first on <a rel="nofollow" href="http://lifelinux.com">lifeLinux: Linux Tips, Hacks, Tutorials, Ebooks</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>http://lifelinux.com/how-to-install-varnish-3-on-centos/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
