<?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>How to Config &#187; Squid</title>
	<atom:link href="http://www.howtoconfig.com/tag/squid/feed" rel="self" type="application/rss+xml" />
	<link>http://www.howtoconfig.com</link>
	<description>how to config - how to configure</description>
	<lastBuildDate>Fri, 29 Apr 2011 09:52:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Check Transparent Proxy</title>
		<link>http://www.howtoconfig.com/os/debian/check-transparent-proxy.html</link>
		<comments>http://www.howtoconfig.com/os/debian/check-transparent-proxy.html#comments</comments>
		<pubDate>Mon, 01 Sep 2008 05:18:35 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Shell script]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[Transparent]]></category>
		<category><![CDATA[TransparentProxy]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=43</guid>
		<description><![CDATA[คือมี case ที่ต้องทำ transparent proxy ครับ  แต่ว่าเวลา proxy มีปัญหา ผมอยากให้ทำการ ปลด proxy ออกเอง  ผมเลยเขียน shell script  มาเพื่อทำการ ตรวจสอบว่า proxy ทำได้หรือเปล่า ถ้าทำงานได้ ก็จะเพิ่ม iptables  ทำการสร้าง DNAT  ไปยังเครื่อง Proxy ครับ หลักกาารง่ายๆคือ  จะใช้ curl แล้ว set proxy เป็นเครื่อง Proxy ที่เรากำหนด   เสร็จแล้วก็ให้ curl ทำการ connect ไปยัง web ปลายทาง   ถ้า connect ได้ content ที่ return มาจาก curl จะมากกว่า 0    และทำให้ [...]]]></description>
			<content:encoded><![CDATA[<p>คือมี case ที่ต้องทำ transparent proxy ครับ  แต่ว่าเวลา proxy มีปัญหา ผมอยากให้ทำการ ปลด proxy ออกเอง  ผมเลยเขียน shell script  มาเพื่อทำการ ตรวจสอบว่า proxy ทำได้หรือเปล่า ถ้าทำงานได้ ก็จะเพิ่ม iptables  ทำการสร้าง DNAT  ไปยังเครื่อง Proxy ครับ</p>
<p><span id="more-43"></span></p>
<p>หลักกาารง่ายๆคือ  จะใช้ curl แล้ว set proxy เป็นเครื่อง Proxy ที่เรากำหนด   เสร็จแล้วก็ให้ curl ทำการ connect ไปยัง web ปลายทาง   ถ้า connect ได้ content ที่ return มาจาก curl จะมากกว่า 0    และทำให้ script เพิ่ม iptables  เข้าไปครับผม</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#	Check Proxy	v.10</span>
<span style="color: #666666; font-style: italic;">#	By Auttasak Wongkitta</span>
<span style="color: #666666; font-style: italic;">#	http://howtoconfig.com</span>
&nbsp;
<span style="color: #007800;">PROXY</span>=<span style="color: #ff0000;">&quot;192.168.100.254:3128&quot;</span>
<span style="color: #007800;">URL</span>=<span style="color: #ff0000;">&quot;http://manager.co.th&quot;</span>
<span style="color: #007800;">LINUX_IP</span>=<span style="color: #ff0000;">&quot;192.168.100.254&quot;</span>
<span style="color: #007800;">LINUX_IF</span>=<span style="color: #ff0000;">&quot;eth2.1&quot;</span>
&nbsp;
<span style="color: #007800;">RESULT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>curl <span style="color: #660033;">-x</span> <span style="color: #007800;">$PROXY</span>  <span style="color: #007800;">$URL</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">USEPROXY</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-L</span> PREROUTING <span style="color: #660033;">-n</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #007800;">$PROXY</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$RESULT</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$USEPROXY</span> <span style="color: #660033;">-ne</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-D</span> PREROUTING <span style="color: #660033;">-i</span> <span style="color: #007800;">$LINUX_IF</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #007800;">$LINUX_IP</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> http <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$PROXY</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$USEPROXY</span> <span style="color: #660033;">-eq</span> <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> PREROUTING <span style="color: #660033;">-i</span> <span style="color: #007800;">$LINUX_IF</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #007800;">$LINUX_IP</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> http <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to</span> <span style="color: #007800;">$PROXY</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fdebian%2Fcheck-transparent-proxy.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/debian/check-transparent-proxy.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>พรบ. การกระทำความผิดเกี่ยวกับคอมพิวเตอร์ &#8211; Revert Proxy Log Rotate</title>
		<link>http://www.howtoconfig.com/os/debian/revert_proxy_log_rotate.html</link>
		<comments>http://www.howtoconfig.com/os/debian/revert_proxy_log_rotate.html#comments</comments>
		<pubDate>Sat, 23 Aug 2008 19:19:50 +0000</pubDate>
		<dc:creator>อัทศักดิ์ วงศ์กิตตะ</dc:creator>
				<category><![CDATA[debian]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Shell script]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Log]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Revert]]></category>
		<category><![CDATA[Rotate]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[พรบ]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=39</guid>
		<description><![CDATA[ตามที่ พรบ  ได้กำหนดให้ &#8220;ผู้ให้บริการ&#8221; เก็บ log การใช้บริการ   โชคดีที่ผมมี Revert Proxy วางไว้หน้า Web Server  ทำให้สามารถเก็บ Log ได้ง่ายหน่อย   ตัว script ที่ผมเขียนนี้ จะทำการ rotate log และ compress log ไว้    ใน version ต่อไป จะทำการ ftp ไปไว้ยัง Log Server  อื่น แทนครับ #!/bin/sh # #    Howtoconfig.com #    Squid Log Rotate v0.1 #    By Mr. Auttasak Wongkitta &#160; SQUID_CONF=&#34;/etc/squid/squid.conf&#34; COMPRESS=yes LOG=&#34;/var/log/backup_log&#34; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>ตามที่ พรบ  ได้กำหนดให้ &#8220;ผู้ให้บริการ&#8221; เก็บ log การใช้บริการ   โชคดีที่ผมมี Revert Proxy วางไว้หน้า Web Server  ทำให้สามารถเก็บ Log ได้ง่ายหน่อย   ตัว script ที่ผมเขียนนี้ จะทำการ rotate log และ compress log ไว้    ใน version ต่อไป จะทำการ ftp ไปไว้ยัง Log Server  อื่น แทนครับ <img src='http://www.howtoconfig.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<span id="more-39"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#    Howtoconfig.com</span>
<span style="color: #666666; font-style: italic;">#    Squid Log Rotate v0.1</span>
<span style="color: #666666; font-style: italic;">#    By Mr. Auttasak Wongkitta</span>
&nbsp;
<span style="color: #007800;">SQUID_CONF</span>=<span style="color: #ff0000;">&quot;/etc/squid/squid.conf&quot;</span>
<span style="color: #007800;">COMPRESS</span>=<span style="color: #c20cb9; font-weight: bold;">yes</span>
<span style="color: #007800;">LOG</span>=<span style="color: #ff0000;">&quot;/var/log/backup_log&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">###############################</span>
<span style="color: #007800;">DATE</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y%m%d-%H&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">HOSTNAME</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">hostname</span> -s<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">SQUID_PATH</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">whereis</span> squid <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #007800;">SQUID_LOG</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$SQUID_CONF</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;^access_log&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $2}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-z</span> <span style="color: #007800;">$SQUID_LOG</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot; * Error : access_log not found!!!&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #007800;">SQUID_LOG_NEW</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SQUID_LOG</span>-<span style="color: #007800;">$HOSTNAME</span>-<span style="color: #007800;">$DATE</span>&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">###############################</span>
Log<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
<span style="color: #7a0874; font-weight: bold;">local</span> LogText;
<span style="color: #007800;">LogText</span>=<span style="color: #ff0000;">&quot;$@&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%d/%m/%y %T&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>  <span style="color: #ff0000;">&quot;   &quot;</span> <span style="color: #007800;">$LogText</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #007800;">$LOG</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
<span style="color: #666666; font-style: italic;">###############################</span>
<span style="color: #666666; font-style: italic;">###############################</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
Log <span style="color: #ff0000;">&quot;--------------------------------------------&quot;</span>
Log <span style="color: #ff0000;">&quot;Squid log rotate - startup&quot;</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
Log <span style="color: #ff0000;">&quot;Rotate Log&quot;</span>
<span style="color: #007800;">$SQUID_PATH</span> <span style="color: #660033;">-k</span> rotate
Log <span style="color: #ff0000;">&quot;done&quot;</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
Log <span style="color: #ff0000;">&quot;Loop check <span style="color: #007800;">$SQUID_LOG</span>.0&quot;</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$SQUID_LOG</span>.0 <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">1</span>;
<span style="color: #000000; font-weight: bold;">done</span>
Log <span style="color: #ff0000;">&quot;done&quot;</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
Log <span style="color: #ff0000;">&quot;Move <span style="color: #007800;">$SQUID_LOG</span>.0 <span style="color: #007800;">$SQUID_LOG_NEW</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #007800;">$SQUID_LOG</span>.0 <span style="color: #007800;">$SQUID_LOG_NEW</span>
Log <span style="color: #ff0000;">&quot;done&quot;</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$SQUID_LOG_NEW</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
Log <span style="color: #ff0000;">&quot;MD5 Sum : <span style="color: #007800;">$SQUID_LOG_NEW</span>&quot;</span>
<span style="color: #007800;">SQUID_MD5</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>md5sum <span style="color: #007800;">$SQUID_LOG_NEW</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Log <span style="color: #ff0000;">&quot;Checksum : <span style="color: #007800;">$SQUID_MD5</span>&quot;</span>
Log <span style="color: #ff0000;">&quot;done&quot;</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$COMPRESS</span>==<span style="color: #ff0000;">'yes'</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
Log <span style="color: #ff0000;">&quot;Compress log <span style="color: #007800;">$SQUID_LOG_NEW</span>&quot;</span>
<span style="color: #007800;">SIZE_OLD</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-sh</span> <span style="color: #007800;">$SQUID_LOG_NEW</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> jpcf <span style="color: #007800;">$SQUID_LOG_NEW</span>.tar.bz2 <span style="color: #007800;">$SQUID_LOG_NEW</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
<span style="color: #007800;">SIZE_NEW</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-sh</span> <span style="color: #007800;">$SQUID_LOG_NEW</span>.tar.bz2 <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $1}'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Log <span style="color: #ff0000;">&quot;Compress from <span style="color: #007800;">$SIZE_OLD</span> -&amp;gt; <span style="color: #007800;">$SIZE_NEW</span>&quot;</span>
Log <span style="color: #ff0000;">&quot;done&quot;</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$SQUID_LOG_NEW</span>.tar.bz2 <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
Log <span style="color: #ff0000;">&quot;Remove file : <span style="color: #007800;">$SQUID_LOG_NEW</span>&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$SQUID_LOG_NEW</span>
Log <span style="color: #ff0000;">&quot;done&quot;</span>
Log <span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
Log <span style="color: #ff0000;">&quot;&quot;</span>
Log <span style="color: #ff0000;">&quot;End&quot;</span></pre></div></div>

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fdebian%2Frevert_proxy_log_rotate.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/debian/revert_proxy_log_rotate.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>วิธีติดตั้ง Reverse Proxy ด้วย Squid</title>
		<link>http://www.howtoconfig.com/os/ubuntu/how-to-implement-squid-reverse-proxy.html</link>
		<comments>http://www.howtoconfig.com/os/ubuntu/how-to-implement-squid-reverse-proxy.html#comments</comments>
		<pubDate>Fri, 11 Jul 2008 12:25:40 +0000</pubDate>
		<dc:creator>กวิน ชัยเลิศ</dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[HTTP traffic]]></category>
		<category><![CDATA[httpd-accelerator]]></category>
		<category><![CDATA[Implement]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[Reverse Proxy]]></category>
		<category><![CDATA[Squid]]></category>
		<category><![CDATA[transparent cache]]></category>

		<guid isPermaLink="false">http://www.howtoconfig.com/?p=32</guid>
		<description><![CDATA[ในเบื่องต้นผมขอแนะนำให้รู้จัก Squid กันก่อนครับ Squid เป็น Open Source Software ที่ให้บริการ Proxy caches ซึ่ง Squid สามารถติดตั้งให้ทำงานใน 3 รูปแบบหลักดังนี้ 1. Standard Proxy Cache ใช้สำหรับเก็บ cache ของ static web pages จำพวก html และรูปภาพ โดยทั่วไปมักจะถูกใช้งานใน network ภายในองค์กร โดยที่ web pages ต่างๆ ที่ถูกเรียกผ่าน local network เป็นครั้งที่สอง web browser จะแสดงผล web pages นั้นผ่าน proxy cache แทนที่ไปดึงข้อมูลจาก web server มาแสดงผล (ประหยัด bandwidth และเพิ่มความเร็วในการแสดงผล) [...]]]></description>
			<content:encoded><![CDATA[<p>ในเบื่องต้นผมขอแนะนำให้รู้จัก Squid กันก่อนครับ</p>
<p>Squid เป็น Open Source Software ที่ให้บริการ Proxy caches ซึ่ง Squid สามารถติดตั้งให้ทำงานใน 3 รูปแบบหลักดังนี้</p>
<p><strong>1. Standard Proxy Cache</strong><br />
ใช้สำหรับเก็บ cache ของ static web pages จำพวก html และรูปภาพ โดยทั่วไปมักจะถูกใช้งานใน network ภายในองค์กร โดยที่ web pages ต่างๆ ที่ถูกเรียกผ่าน local network เป็นครั้งที่สอง web browser จะแสดงผล web pages นั้นผ่าน proxy cache แทนที่ไปดึงข้อมูลจาก web server มาแสดงผล (ประหยัด bandwidth และเพิ่มความเร็วในการแสดงผล)</p>
<p><strong>2. Transparent Cache</strong><br />
ความสามารถหลักๆ เหมือนกับการติดตั้งแบบ standard proxy cache จะแตกต่างกันที่การติดตั้งแบบ transparent cache ไม่จำเป็นต้องปรับแต่ง web browser ให้สามารถใช้งาน proxy cache โดยที่ transparent cache จะทำหน้าที่คอยกรอง HTTP traffic (on port 80) แล้วตรวจสอบว่า request นั้นมีอยู่ใน cahce หรือไม่ ถ้าไม่มีก็จะทำการส่งต่อไปยัง web server ของ web pages นั้น (สำหรับ Linux การใช้งาน transparent cache จะใช้ควบคู่ไปกับ iptables ในการกรอง HTTP traffic)</p>
<p><strong>3. Reverse Proxy Cache</strong><br />
สำหรับ reverse proxy cache จะทำหน้าที่แตกต่างกับ standard และ transparent caches โดยที่ reverse proxy cache จะทำหน้าที่ลดภาระของ web server แทนที่การลด network bandwidth ของฝั่ง client กล่าวคือ reverse proxy cache ถูกติดตั้งอยู่หน้า web server (ระหว่าง internet และ web server) คอยจัดการ traffic ที่เกิดขึ้นทั้งหมดก่อนจะถึง web server ป้องกัน traffic ที่เพิ่มขึ้นโดยไม่พีงประสงค์ (ซึ่งอาจจะโดนโจมตีจาก hacker เป็นต้น) อีกทั้งยังลดภาระของ web server อีกทางนึง<br />
<img class="alignnone size-full image-33" title="reverse-proxy" src="http://www.howtoconfig.com/content/uploads/2008/07/reverse-proxy.gif" alt="" width="436" height="451" /><br />
<span id="more-32"></span><br />
สำหรับวิธีการติดตั้ง Reverse Proxy ด้วย Squid สามารถทำตามขั้นตอนต่อไปนี้ได้เลยครับ<br />
(ทำการติดตั้งบน CentOS 4.6)</p>
<p>ตรวจสอบว่าได้ติดตั้ง squid แล้วหรือยัง</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">rpm <span style="color: #660033;">-qa</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">grep</span> squid</pre></div></div>

<p>ถ้าได้ทำการติดตั้ง squid ไว้แล้วจะแสดงผลของคำสั้งตามตัวอย่างครับ</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">[root@reverse ~]# rpm -qa|grep squid
squid-2.5.STABLE14-1.4E.el4_6.2
[root@reverse ~]#</pre></div></div>

<p>กรณียังไม่ได้ติดตั้งให้ใช้คำสั่ง yum install squid ได้เลยครับ</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">yum <span style="color: #c20cb9; font-weight: bold;">install</span> squid</pre></div></div>

<p>หลังจากทำการติดตั้ง squid เรียบร้อยแล้วให้ทำการปรับแต่งไฟล์ /etc/squid/squid.conf โดยแก้ไขเพิ่มเติม options เหล่านี้</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">http_port 80 #Port ของ Squid
httpd_accel_host 192.168.0.2 #IP address ของ Web Server (แทนที่ public ip 203.101.102.1 ด้วย private ip 192.168.0.2)
httpd_accel_port 80 #Port ของ Web Server
httpd_accel_single_host on #Option on ใช้ในกรณีที่ต้องการติดตั้ง Reverse Proxy ไว้หน้า Web Server เดี่ยวๆ
httpd_accel_with_proxy on
httpd_accel_uses_host_header off</pre></div></div>

<p>เพียงเท่านี้ก็สามารถใช้งาน Reverse Proxy ได้แล้ว รับรองว่าสามารถลดภาระการทำงานของ Web Server แน่นอน<br />
หากเพื่อนๆ มีข้อสงสัยหรือข้อเสนอแนะ &#8230; ก็ comment ไว้ด้วยนะครับ</p>
<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.howtoconfig.com%2Fos%2Fubuntu%2Fhow-to-implement-squid-reverse-proxy.html&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>]]></content:encoded>
			<wfw:commentRss>http://www.howtoconfig.com/os/ubuntu/how-to-implement-squid-reverse-proxy.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

