<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://kb.linux-vs.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wokfel</id>
		<title>LVSKB - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://kb.linux-vs.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wokfel"/>
		<link rel="alternate" type="text/html" href="http://kb.linux-vs.org/wiki/Special:Contributions/Wokfel"/>
		<updated>2026-04-20T04:43:35Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://kb.linux-vs.org/wiki?title=Building_clusterized_proxy_farms_using_LVS&amp;diff=5839</id>
		<title>Building clusterized proxy farms using LVS</title>
		<link rel="alternate" type="text/html" href="http://kb.linux-vs.org/wiki?title=Building_clusterized_proxy_farms_using_LVS&amp;diff=5839"/>
				<updated>2010-10-15T07:13:42Z</updated>
		
		<summary type="html">&lt;p&gt;Wokfel: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
Sometimes, you just need to build a proxy farm with the following needs:&lt;br /&gt;
*you need high-availability, because of your SLA.&lt;br /&gt;
*you need load balancing, because you're serving numerous Kusers.&lt;br /&gt;
*you need caching with Squid.&lt;br /&gt;
*you need extra-services over Squid (URL filtering with DansGuardian/SquidGuard, Antivirus softwares, ...)&lt;br /&gt;
*you need scalability because you want to be able to grow.&lt;br /&gt;
&lt;br /&gt;
Acai Berry is the best supplement available in the market. [http://www.articlesbase.com/supplements-and-vitamins-articles/my-weight-loss-experience-with-the-acai-berry-diet-1726693.html Acai Berry] has been a revolution and is preferred by most of the people. There are various benefits of [http://www.buzzle.com/articles/the-facts-and-half-truths-about-the-acai-berry-diet.html] but they are questioned at times. It is quite helpful for the weight losers and this fruit also provides you with enormous amount of energy.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In these cas, you've got plenty of answers to proceed. [[LVS]] is one of them (probably the best suited anyway).&lt;br /&gt;
&lt;br /&gt;
But as you're doing extra-services over Squid, the base [[LVS]] [[ldirectord]] tests won't be sufficient.&lt;br /&gt;
&lt;br /&gt;
This page explains how to make some more advanced tests to be sure some extra-services will be checked too, and the corresponding realserver service will be dropped down if one of the extra service (or Squid itself) is not available.&lt;br /&gt;
&lt;br /&gt;
It present a proposed patch to [[ldirectord]] to do so.&lt;br /&gt;
&lt;br /&gt;
== Architecture ==&lt;br /&gt;
&lt;br /&gt;
The system architecture of web cache cluster using [[LVS]] is illustrated in the following figure.&lt;br /&gt;
&lt;br /&gt;
 [[Image:sl-ha-lb-overview-ultramonkey3.png|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* it uses [[LVS]] with Ultramonkey 3 settings for a [http://www.ultramonkey.org/3/topologies/sl-ha-lb-overview.html Streamline High Availability and Load Balancing] setting.&lt;br /&gt;
* it's based on the usage for Squid + DansGuardian (but could feet for any Squid + *).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Configuration Example ==&lt;br /&gt;
To set up this configuration with [[LVS]], just proceed to [http://www.ultramonkey.org/3/installation.html installation] and [http://www.ultramonkey.org/3/topologies/sl-ha-lb-eg.html configuration] as indicated on the Ultramonkey documentations.&lt;br /&gt;
&lt;br /&gt;
Then :&lt;br /&gt;
* set up your Squid server, listening on port 3128 (example) and using DansGuardian on port 8000&lt;br /&gt;
* set up your DansGuardian server, listening to port 8000&lt;br /&gt;
* set up DansGuardian to reject (filter) the &amp;quot;http://proxy.testing.net/&amp;quot; URL (adding this domain/url to the blacklists. Be sure the &amp;quot;URL Filtering&amp;quot; will be returned by the proxy in case of filtering this URL.&lt;br /&gt;
* patch /usr/sbin/ldirectord with the FIXME patch&lt;br /&gt;
* configure your /etc/ha.d/ldirectord.cf with the following tests (example IP addresses):&lt;br /&gt;
&lt;br /&gt;
 # /etc/ha.d/ldirectord.cf&lt;br /&gt;
 # Virtual Server for Proxy Service and Filtering Service&lt;br /&gt;
 virtual=192.168.0.100:3128&lt;br /&gt;
         real=192.168.0.10:3128 gate&lt;br /&gt;
         real=192.168.0.11:3128 gate&lt;br /&gt;
         real=192.168.0.12:3128 gate&lt;br /&gt;
         real=192.168.0.12:3128 gate&lt;br /&gt;
         service=proxy_http&lt;br /&gt;
         request=&amp;quot;http://proxy.testing.net&amp;quot;&lt;br /&gt;
         receive=&amp;quot;URL Filtering&amp;quot;&lt;br /&gt;
         protocol=tcp&lt;br /&gt;
         scheduler=wlc&lt;br /&gt;
         protocol=tcp&lt;br /&gt;
         checktype=negotiate&lt;br /&gt;
&lt;br /&gt;
== Conclusion ==&lt;br /&gt;
If you were using http test, you could only be able to check Squid is running. In case of DansGuardian issue, it could be a bad thing. This way, if the filtering engine is down/not responding, the whole Squid realserver will be dropped down for [[LVS]].&lt;br /&gt;
&lt;br /&gt;
Of course, you must still monitor all process to be warned anything is going wrong. But you will have time to resolve as your users won't notice anything :) Thank's a lot to [[LVS]] again!&lt;br /&gt;
&lt;br /&gt;
== The ldirectord patch ==&lt;br /&gt;
This patch is to be applied to release +ldirectord,v 1.77.2.32+, but is basic enought for you to report it to any newer release of [[ldirectord]].&lt;br /&gt;
&lt;br /&gt;
 --- ldirectord_sav	2005-10-03 08:18:19.000000000 +0200&lt;br /&gt;
 +++ ldirectord	2005-11-13 14:39:51.000000000 +0100&lt;br /&gt;
 @@ -236,7 +236,7 @@ checking will take place and no real or &lt;br /&gt;
  On means no checking will take place and real servers will always be&lt;br /&gt;
  activated. Default is I&amp;lt;negotiate&amp;gt;.&lt;br /&gt;
  &lt;br /&gt;
 -B&amp;lt;service = ftp&amp;gt;|B&amp;lt;smtp&amp;gt;|B&amp;lt;http&amp;gt;|B&amp;lt;pop&amp;gt;|B&amp;lt;nntp&amp;gt;|B&amp;lt;imap&amp;gt;|B&amp;lt;ldap&amp;gt;|B&amp;lt;https&amp;gt;|B&amp;lt;dns&amp;gt;|B&amp;lt;mysql&amp;gt;|B&amp;lt;pgsql&amp;gt;|B&amp;lt;sip&amp;gt;|B&amp;lt;none&amp;gt;&lt;br /&gt;
 +B&amp;lt;service = ftp&amp;gt;|B&amp;lt;smtp&amp;gt;|B&amp;lt;http&amp;gt;|B&amp;lt;proxy_http&amp;gt;|B&amp;lt;pop&amp;gt;|B&amp;lt;nntp&amp;gt;|B&amp;lt;imap&amp;gt;|B&amp;lt;ldap&amp;gt;|B&amp;lt;https&amp;gt;|B&amp;lt;dns&amp;gt;|B&amp;lt;mysql&amp;gt;|B&amp;lt;pgsql&amp;gt;|B&amp;lt;sip&amp;gt;|B&amp;lt;none&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
  The type of service to monitor when using checktype=negotiate. None denotes&lt;br /&gt;
  a service that will not be monitored. If the port specfied for the virtual&lt;br /&gt;
 @@ -866,8 +866,8 @@ sub read_config&lt;br /&gt;
  					}&lt;br /&gt;
  				} elsif ($rcmd =~ /^service\s*=\s*(.*)/) {&lt;br /&gt;
  					lc($1);&lt;br /&gt;
 -					$1 =~ /(\w+)/ &amp;amp;&amp;amp; ($1 eq &amp;quot;http&amp;quot; || $1 eq &amp;quot;https&amp;quot; || $1 eq &amp;quot;ldap&amp;quot; || $1 eq &amp;quot;ftp&amp;quot; || $1 eq &amp;quot;none&amp;quot; || $1 eq &amp;quot;smtp&amp;quot; || $1 eq &amp;quot;pop&amp;quot; || $1 eq &amp;quot;imap&amp;quot; || $1 eq &amp;quot;nntp&amp;quot; || $1 eq &amp;quot;dns&amp;quot; || $1 eq &amp;quot;mysql&amp;quot; || $1 eq &amp;quot;pgsql&amp;quot; || $1 eq &amp;quot;sip&amp;quot;)&lt;br /&gt;
 -					    or &amp;amp;config_error($line, &amp;quot;service must be http, https, ftp, smtp, pop, imap, ldap, nntp, dns, mysql, pgsql, sip, or none&amp;quot;);&lt;br /&gt;
 +					$1 =~ /(\w+)/ &amp;amp;&amp;amp; ($1 eq &amp;quot;http&amp;quot; || $1 eq &amp;quot;proxy_http&amp;quot; || $1 eq &amp;quot;https&amp;quot; || $1 eq &amp;quot;ldap&amp;quot; || $1 eq &amp;quot;ftp&amp;quot; || $1 eq &amp;quot;none&amp;quot; || $1 eq &amp;quot;smtp&amp;quot; || $1 eq &amp;quot;pop&amp;quot; || $1 eq &amp;quot;imap&amp;quot; || $1 eq &amp;quot;nntp&amp;quot; || $1 eq &amp;quot;dns&amp;quot; || $1 eq &amp;quot;mysql&amp;quot; || $1 eq &amp;quot;pgsql&amp;quot; || $1 eq &amp;quot;sip&amp;quot;)&lt;br /&gt;
 +					    or &amp;amp;config_error($line, &amp;quot;service must be http, https, proxy_http, ftp, smtp, pop, imap, ldap, nntp, dns, mysql, pgsql, sip, or none&amp;quot;);&lt;br /&gt;
  					$vsrv{service} = $1;&lt;br /&gt;
  					if($vsrv{service} eq &amp;quot;ftp&amp;quot; and &lt;br /&gt;
  							$vsrv{login} eq &amp;quot;&amp;quot;) {&lt;br /&gt;
 @@ -1635,6 +1635,8 @@ sub ld_main&lt;br /&gt;
  						$$r{num_connects} = 0 if (check_http($v, $r));&lt;br /&gt;
  						# my $req = new HTTP::Request(GET=&amp;gt;&amp;quot;$$r{url}&amp;quot;);&lt;br /&gt;
  						# $ua-&amp;gt;register($req, \&amp;amp;http_received);&lt;br /&gt;
 +					} elsif ($$v{service} eq &amp;quot;proxy_http&amp;quot;) {&lt;br /&gt;
 +						$$r{num_connects} = 0 if (check_proxy_http($v, $r));&lt;br /&gt;
  					} elsif ($$v{service} eq &amp;quot;pop&amp;quot;) {&lt;br /&gt;
  						$$r{num_connects} = 0 if (check_pop($v, $r));&lt;br /&gt;
  					} elsif ($$v{service} eq &amp;quot;imap&amp;quot;) {&lt;br /&gt;
 @@ -1693,6 +1695,51 @@ sub ld_main&lt;br /&gt;
  	}&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
 +sub check_proxy_http&lt;br /&gt;
 +{&lt;br /&gt;
 +        use LWP::UserAgent;&lt;br /&gt;
 +        use LWP::Debug;&lt;br /&gt;
 +&lt;br /&gt;
 +        my ($v, $r) = @_;&lt;br /&gt;
 +&lt;br /&gt;
 +	my $proxy_request = substr($$r{request},1);&lt;br /&gt;
 +&lt;br /&gt;
 +        my $ua = new LWP::UserAgent();&lt;br /&gt;
 +&lt;br /&gt;
 +        $ua-&amp;gt;timeout($$v{negotiatetimeout});&lt;br /&gt;
 +        $ua-&amp;gt;proxy(['http', 'ftp'], &amp;quot;http://$$r{server}:$$r{port}/&amp;quot;);&lt;br /&gt;
 +&lt;br /&gt;
 +        my $h = new  HTTP::Headers(&amp;quot;Host&amp;quot; =&amp;gt; $$v{virtualhost});&lt;br /&gt;
 +        my $req = new HTTP::Request(&amp;quot;$$v{httpmethod}&amp;quot;, &amp;quot;$proxy_request&amp;quot;, $h);&lt;br /&gt;
 +&lt;br /&gt;
 +        my $res;&lt;br /&gt;
 +        {&lt;br /&gt;
 +		 # LWP makes ungaurded calls to eval&lt;br /&gt;
 +		 # which throw a fatal exception if they fail&lt;br /&gt;
 +		 # Needless to say, this is completely stupid.&lt;br /&gt;
 +		 local $SIG{'__DIE__'} = &amp;quot;DEFAULT&amp;quot;;&lt;br /&gt;
 +                 $res = $ua-&amp;gt;request($req);&lt;br /&gt;
 +         }&lt;br /&gt;
 +&lt;br /&gt;
 +        my $recstr = $$v{receive};&lt;br /&gt;
 +&lt;br /&gt;
 +        if ($res-&amp;gt;is_success &amp;amp;&amp;amp; (!($recstr =~ /.+/) || $res-&amp;gt;content =~ /$recstr/)) {&lt;br /&gt;
 +		service_set($v, $r, &amp;quot;up&amp;quot;);&lt;br /&gt;
 +                &amp;amp;ld_debug(2, &amp;quot;check_proxy_http: $proxy_request is up\n&amp;quot;);&lt;br /&gt;
 +                return 1;&lt;br /&gt;
 +        }&lt;br /&gt;
 +	&lt;br /&gt;
 +	service_set($v, $r, &amp;quot;down&amp;quot;);&lt;br /&gt;
 +        &amp;amp;ld_debug(3, &amp;quot;Headers &amp;quot; .  $res-&amp;gt;headers-&amp;gt;as_string);&lt;br /&gt;
 +        &amp;amp;ld_debug(2, &amp;quot;check_proxy_http: $proxy_request is down\n&amp;quot;);&lt;br /&gt;
 +        return 0;&lt;br /&gt;
 +&lt;br /&gt;
 +}&lt;br /&gt;
 &lt;br /&gt;
More infos? mailto:christian.avramakis@siemens.com&lt;br /&gt;
[[Category:LVS Examples|Cache]]&lt;/div&gt;</summary>
		<author><name>Wokfel</name></author>	</entry>

	</feed>