<?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>logIt &#187; squid</title>
	<atom:link href="https://lakm.us/logit/tag/squid/feed/" rel="self" type="application/rss+xml" />
	<link>https://lakm.us/logit</link>
	<description>Log Around The Clock</description>
	<lastBuildDate>Sat, 06 Jun 2015 14:17:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Running Two Squid Instances in Upstart Init</title>
		<link>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/</link>
		<comments>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/#comments</comments>
		<pubDate>Fri, 10 May 2013 08:55:16 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=644</guid>
		<description><![CDATA[After installing squid3 from repository, Ubuntu will place the init in upstart style (instead of /etc/rc*.d/ or /etc/init.d/ style used to maintain backward compatibility to legacy System-V init). The upstart job is placed in /etc/init/squid3.conf with default runlevel (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using service: $ sudo [...]]]></description>
				<content:encoded><![CDATA[<p>After installing <a href="http://www.squid-cache.org/" target="_blank">squid3</a> from <a href="http://packages.ubuntu.com/precise/squid3" target="_blank">repository</a>, Ubuntu will place the <code>init</code> in <a href="http://upstart.ubuntu.com/" target="_blank">upstart</a> style (instead of <code>/etc/rc*.d/</code> or <code>/etc/init.d/</code> style used to maintain backward compatibility to legacy <a href="http://en.wikipedia.org/wiki/Init" target="_blank">System-V init</a>). The upstart job is placed in <code>/etc/init/squid3.conf</code> with default <code>runlevel</code> (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using <code>service</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> service squid3 <span style="color: #7a0874; font-weight: bold;">&#123;</span>start<span style="color: #000000; font-weight: bold;">|</span>stop<span style="color: #000000; font-weight: bold;">|</span>restart<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>To specify what to run, an <code>upstart</code> <a href="http://upstart.ubuntu.com/getting-started.html" target="_blank">must have</a> <code>exec</code> or <code>script</code> stanza. When the goal is to start two or more (multiple) instances of <code>squid3</code>, <code>exec</code> is meant <a href="http://manpages.ubuntu.com/manpages/precise/man3/exec.3.html" target="_blank">to replace existing process image</a> of <code>/usr/sbin/squid3</code> executable, therefore will not start two instances.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Eltek Smartpack Controller type with SNMP Support" src="../../../../images/squid3-two-instances-illustration.png" title="Multiple squid3 instances started via upstart exec" width="385" height="188" /><p class="wp-caption-text">Multiple squid3 instances started via upstart exec</p></div>
<p>As workaround we can have symbolic link to <code>squid3</code> executable instead and add new <code>upstart</code> job configuration with <code>exec</code> call to the link. I need two instances running in the same machine due to the implementation design where the fist instance is HTTP proxy cache while the second one is accelerator/interceptor (reverse proxy) that serves default landing page telling user to use proxy (and how to do that). Hence, for the second instance I add:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">lrwxrwxrwx <span style="color: #000000;">1</span> root root <span style="color: #000000;">6</span> May  <span style="color: #000000;">3</span> 09:<span style="color: #000000;">25</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>squid3ins2 -<span style="color: #000000; font-weight: bold;">&gt;</span> squid3
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">1156</span> May  <span style="color: #000000;">6</span> <span style="color: #000000;">13</span>:<span style="color: #000000;">30</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>squid3ins2.conf</pre></div></div>

<p>and for the first instance I add:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">298</span> May  <span style="color: #000000;">3</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">13</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>squid3.override</pre></div></div>

<p><code>squid3ins2</code> is our link and <code>/etc/init/squid3ins2.conf</code> contains <code>exec</code> call to it to run second <code>squid3</code>. For the first instance I choose to write an override (<code>/etc/init/squid3.override</code>) so that the original job configuration file is left intact. For the complete content of all files check <a href="https://github.com/bandono/proxyConf/tree/v1.1/init" target="_blank">my github v1.1</a> of the Squid integration. There, in details you&#8217;ll also find how both instances PID, log, etc. are differentiated by each instance config via the following directives:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">http_port
cache_dir
pid_filename
cache_access_log
cache_log</pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Basic squid In A Gateway</title>
		<link>https://lakm.us/logit/2009/08/basic-squid-in-a-gateway/</link>
		<comments>https://lakm.us/logit/2009/08/basic-squid-in-a-gateway/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 08:26:59 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[router]]></category>
		<category><![CDATA[squid]]></category>

		<guid isPermaLink="false">http://localhost/it/?p=73</guid>
		<description><![CDATA[This trial is done in a RedHat (RHEL 5.2) inside VirtualBox. The required squid package is using squid-3.0.STABLE13-1.el5.i386.rpm. Two interfaces is configured in this box as shown in the following NAT masquerading which build a simple router at 192.168.40.40 (eth1) : 1 2 3 4 5 6 7 8 WAN=wan0 LAN=eth1 IPTABLES=/sbin/iptables &#160; $IPTABLES --flush                         [...]]]></description>
				<content:encoded><![CDATA[<p>This trial is done in a RedHat (RHEL 5.2) inside VirtualBox. The required squid package is using <code>squid-3.0.STABLE13-1.el5.i386.rpm</code>. Two interfaces is configured in this box as shown in the following NAT masquerading which build a simple router at <code>192.168.40.40</code> (<code>eth1</code>) :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">WAN</span>=wan0
<span style="color: #007800;">LAN</span>=eth1
<span style="color: #007800;">IPTABLES</span>=<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>iptables
&nbsp;
<span style="color: #007800;">$IPTABLES</span> --flush                         <span style="color: #666666; font-style: italic;"># Flush all the rules in filter and nat tables</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">--table</span> nat <span style="color: #660033;">--flush</span>
<span style="color: #007800;">$IPTABLES</span> --delete-chain                  <span style="color: #666666; font-style: italic;"># Delete all chains that are not in default filter and nat table</span>
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">--table</span> nat <span style="color: #660033;">--delete-chain</span></pre></td></tr></table></div>

<p><strong>the real script is just two command line below</strong>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">--table</span> nat <span style="color: #660033;">--append</span> POSTROUTING <span style="color: #660033;">--out-interface</span> <span style="color: #007800;">$WAN</span> <span style="color: #660033;">-j</span> MASQUERADE
<span style="color: #007800;">$IPTABLES</span> <span style="color: #660033;">--append</span> FORWARD <span style="color: #660033;">--in-interface</span> <span style="color: #007800;">$LAN</span> <span style="color: #660033;">-j</span> ACCEPT</pre></td></tr></table></div>

<p>Default route gateway is <code>wan0</code> and <code>/etc/resolv.conf</code> is edited with relevant DNS. Internet works perfectly and then after squid is installed, I use the following <code>/etc/squid.conf</code> :</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">visible_hostname mithrandir
http_port <span style="color: #000000;">3128</span>
cache_dir ufs <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>spool<span style="color: #000000; font-weight: bold;">/</span>squid <span style="color: #000000;">1000</span> <span style="color: #000000;">16</span> <span style="color: #000000;">256</span>
cache_access_log <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>squid<span style="color: #000000; font-weight: bold;">/</span>access.log
acl intranet src 192.168.40.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span>
http_access allow intranet</pre></td></tr></table></div>

<p>It is pretty straightforward and simple, a listening proxy <code>192.168.40.40</code> in port <code>3128</code>. It is also a router to the internet, NAT, via <code>wan0</code>.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2009/08/basic-squid-in-a-gateway/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
