<?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>Squid Archives - ServerStadium</title>
	<atom:link href="https://serverstadium.com/knowledge-base/tag/squid/feed/" rel="self" type="application/rss+xml" />
	<link>https://serverstadium.com/knowledge-base/tag/squid/</link>
	<description>Public Cloud Solution by ServerStadium</description>
	<lastBuildDate>Thu, 27 Apr 2023 10:33:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://serverstadium.com/wp-content/uploads/2023/04/cropped-favicon-1-32x32.png</url>
	<title>Squid Archives - ServerStadium</title>
	<link>https://serverstadium.com/knowledge-base/tag/squid/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Install and Configure Squid Proxy in Ubuntu</title>
		<link>https://serverstadium.com/knowledge-base/installing-and-configuring-squid-proxy-in-ubuntu/</link>
		
		<dc:creator><![CDATA[Brian K]]></dc:creator>
		<pubDate>Fri, 02 Oct 2020 08:48:13 +0000</pubDate>
				<guid isPermaLink="false">https://cloudraya.com/knowledge-base/?p=437</guid>

					<description><![CDATA[<p>Squid is a full-featured web proxy cache server application that provides proxy and cache services for HTTP, FTP, and other popular network protocols that you can easily install in Ubuntu. This guide will show you how to create your own HTTP proxy using Squid, a highly customizable proxy/cache application, in Ubuntu 18.04 VM Instance in&#8230;</p>
<p>The post <a href="https://serverstadium.com/knowledge-base/installing-and-configuring-squid-proxy-in-ubuntu/">Install and Configure Squid Proxy in Ubuntu</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="has-text-align-justify wp-block-paragraph">Squid is a full-featured web proxy cache server application that provides proxy and cache services for HTTP, FTP, and other popular network protocols that you can easily install in Ubuntu.</p>



<p class="wp-block-paragraph">This guide will show you how to create your own HTTP proxy using Squid, a highly customizable proxy/cache application, in Ubuntu 18.04 <a href="https://serverstadium.com/knowledge-base/deploying-a-virtual-machine-in-serverstadium/">VM Instance in ServerStadium</a>.</p>



<p class="has-text-align-justify wp-block-paragraph">An HTTP proxy acts as an intermediary between you and the internet. While connected to your Squid HTTP proxy, you will be able to:</p>



<ul class="wp-block-list">
<li>Anonymously access internet services.</li>
<li>Bypass certain regional and local network restrictions.</li>
</ul>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Installing Squid</h2>



<p class="has-text-align-justify wp-block-paragraph">First, make sure the server is up to date by running the following commands as sudo user:</p>



<pre class="wp-block-code"><code>$ sudo apt update &amp;&amp; sudo apt upgrade</code></pre>



<p class="has-text-align-justify wp-block-paragraph">After you ensure your system is up to date, continue with the Squid Installation.</p>



<pre class="wp-block-code"><code>$ sudo apt install squid</code></pre>



<p class="wp-block-paragraph">Then check the installation by using the following command; if the installation succeeded, it will produce this following output:</p>



<pre class="wp-block-code"><code>$ sudo systemctl status squid

Output:
● squid.service - LSB: Squid HTTP Proxy version 3.x
   Loaded: loaded (/etc/init.d/squid; generated)
   Active: active (running) since Thu 2020-09-17 12:06:07 UTC; 4min 46s ago
     Docs: man:systemd-sysv-generator(8)
.....</code></pre>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Configuring Firewalls</h2>



<p class="has-text-align-justify wp-block-paragraph">We should ensure that our Ubuntu VM Instance Squid Port (TCP Port 3128) is not blocked by ServerStadium Security Profile and UFW Firewall.</p>



<p class="wp-block-paragraph">To modify ServerStadium Cloud Security Profile, open the ServerStadium Cloud panel and navigate to <em><strong>Networking Sidemenu -&gt; Security Profile</strong></em>. Then, edit or create a new Security Profile.<br />Add a new Firewall Rule on the Security Profile page that opens TCP port 3128. Then apply the security profile.</p>



<figure class="wp-block-gallery aligncenter has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex">
<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="505" height="415" data-id="439" class="wp-image-439" src="https://serverstadium.com/wp-content/uploads/2020/09/CP_AddRule.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/09/CP_AddRule.png 505w, https://serverstadium.com/wp-content/uploads/2020/09/CP_AddRule-300x247.png 300w" sizes="(max-width: 505px) 100vw, 505px" /></figure>



<figure class="wp-block-image size-large"><img decoding="async" width="1919" height="495" data-id="444" class="wp-image-444" src="https://serverstadium.com/wp-content/uploads/2020/09/CP_Firewall-1.png" alt="" srcset="https://serverstadium.com/wp-content/uploads/2020/09/CP_Firewall-1.png 1919w, https://serverstadium.com/wp-content/uploads/2020/09/CP_Firewall-1-300x77.png 300w, https://serverstadium.com/wp-content/uploads/2020/09/CP_Firewall-1-1024x264.png 1024w, https://serverstadium.com/wp-content/uploads/2020/09/CP_Firewall-1-768x198.png 768w, https://serverstadium.com/wp-content/uploads/2020/09/CP_Firewall-1-1536x396.png 1536w" sizes="(max-width: 1919px) 100vw, 1919px" /></figure>
</figure>



<p class="wp-block-paragraph">We also need to ensure Inbound TCP port is allowed in Ubuntu UFW. To do this, run the following command in the Ubuntu VM we installed with Squid server.</p>



<pre class="wp-block-code"><code>$ sudo ufw allow 'Squid'</code></pre>



<p class="wp-block-paragraph">To verify the firewall status, type the following command and the output will be shown below</p>



<pre class="wp-block-code"><code>$ sudo ufw status

Output:
Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere                  
Squid                      ALLOW       Anywhere                  
OpenSSH (v6)               ALLOW       Anywhere (v6)             
Squid (v6)                 ALLOW       Anywhere (v6) </code></pre>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Configuring Squid</h2>



<p class="wp-block-paragraph">Now that Squid is installed on our ServerStadium Cloud Ubuntu VM, we can configure it to accept connections and serve as an HTTP proxy.</p>



<p class="wp-block-paragraph">Squid can be configured by editing the <code>/etc/squid/squid.conf</code> file. You can also use separate files with configuration options which can be included using the “include” directive.</p>



<p class="wp-block-paragraph">The configuration file contains comments that describe what each configuration option does.</p>



<p class="wp-block-paragraph">Before making any changes, it is a good practice to back up the original configuration file by running the following commands:</p>



<pre class="wp-block-code"><code>$ sudo cp /etc/squid/squid.conf{,.orginal}</code></pre>



<p class="wp-block-paragraph">Edit the file by opening it using nano (or another text editor):</p>



<pre class="wp-block-code"><code>$ sudo nano /etc/squid/squid.conf</code></pre>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Configuring Client Access via IP ACL</h2>



<p class="wp-block-paragraph">In Squid, you can control how the clients can access the web resources using the Access Control Lists (ACLs).</p>



<p class="wp-block-paragraph">By default, Squid allows access only from the localhost.</p>



<p class="wp-block-paragraph">If all the clients using the proxy have a static IP address, you can create an ACL that includes the allowed IPs.</p>



<p class="wp-block-paragraph">Instead of adding the IP addresses in the main configuration file, we will create a new dedicated file that will hold the IPs:</p>



<pre class="wp-block-code"><code>$ sudo nano /etc/squid/allowSourceIP.txt

192.168.33.1
# All other allowed IPs</code></pre>



<p class="wp-block-paragraph">Once done, open the main configuration file and create a new ACL named <code>allowSourceIP</code> (first highlighted line) and allow access to that ACL using the <code>http_access</code> directive (second highlighted line):</p>



<pre class="wp-block-code"><code># ...
acl allowSourceIP  src "/etc/squid/allowSourceIP.txt"
http_access allow localhost
 #Allow access from localhost
http_access allow allowSourceIP #Allow access from IP List

# And finally deny all other access to this proxy
http_access deny all</code></pre>



<p class="wp-block-paragraph">The <code>http_access</code> directive works similarly to the firewall rules. Squid reads the rules from top to bottom, and when a rule matches, the rules below are not processed.</p>



<p class="wp-block-paragraph">Since the order of <code>http_access</code> rules are important. Make sure you add the line before <code>http_access deny all</code>.</p>



<p class="wp-block-paragraph">Please keep mindful that whenever you make changes to the config file, you need to restart the Squid service with the following command:</p>



<pre class="wp-block-code"><code>$ sudo systemctl restart squid</code></pre>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Configuring Client Access via Basic Authentication</h2>



<p class="wp-block-paragraph">Besides limiting access via IP, we can also configure Squid HTTP proxy via basic HTTP authentication.</p>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<ol class="wp-block-list">
<li>Install htpasswd by installing the Apache utility programs. If you have installed Apache on your Cloudraya Ubuntu VM, you will already have it and can skip this step.</li>
</ol>



<pre class="wp-block-code"><code>$ sudo apt-get install apache2-utils</code></pre>



<p class="wp-block-paragraph">2. Create a file to store Squid users and passwords:</p>



<pre class="wp-block-code"><code>$ sudo touch /etc/squid/squid_usr</code></pre>



<p class="wp-block-paragraph">3. Change ownership of the password file:</p>



<pre class="wp-block-code"><code>$ sudo chown proxy /etc/squid/squid_usr</code></pre>



<p class="wp-block-paragraph">4. Check the location of the <code>ncsa_auth</code> file:</p>



<pre class="wp-block-code"><code>$ sudo dpkg -L squid | grep ncsa_auth</code></pre>



<p class="wp-block-paragraph">5. Edit the Squid configuration file (<code>/etc/squid/squid.conf</code>) and add the following lines at the beginning of the file. Make sure that you update <code>/usr/lib/squid/basic_ncsa_auth</code> below with the location of the <code>ncsa_auth</code> file that you checked in the previous step:</p>
</div></div>



<pre class="wp-block-code"><code>auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/squid_passwd
acl ncsa_users proxy_auth REQUIRED
http_access allow ncsa_users</code></pre>



<p class="wp-block-paragraph">Once you’ve saved and exited the file, complete user removal by restarting Squid:</p>



<pre class="wp-block-code"><code>$ sudo systemctl restart squid</code></pre>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Blocking access to restricted domain</h2>



<p class="wp-block-paragraph">One of the features of Squid proxy server is blocking websites for the client that connects to our Squid Proxy server. It can be done using <code>forbidden dstdomain</code> keyword in <strong>ACL</strong> directive.</p>



<p class="wp-block-paragraph">First, we need to create the file. Then add domain names that we need to restrict:</p>



<pre class="wp-block-code"><code>$ sudo nano /etc/squid/forbidden_domains.txt

Contains:
.facebook.com
.twitter.com
.tiktok.com</code></pre>



<p class="wp-block-paragraph">After we create the list of domains in a text file, we modify the Squid configuration file as follows:</p>



<pre class="wp-block-code"><code># ...
acl allowSourceIP src "/etc/squid/allowSourceIP.txt"

#Add a new ACL directive
acl forbidden dstdomain "/etc/squid/forbidden_domains" 

http_access allow localhost
 #Allow access from localhost
http_access allow allowSourceIP #Allow access from IP List
#Add the restricted server in the deny list
http_access deny forbidden

# And finally deny all other access to this proxy
http_access deny all</code></pre>



<p class="wp-block-paragraph">After that, don&#8217;t forget to restart the Squid service to apply the changes</p>



<pre class="wp-block-code"><code>$ sudo systemctl restart squid</code></pre>



<p class="wp-block-paragraph">&nbsp;</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Anonymizing Traffic</h2>



<p class="wp-block-paragraph">We also can anonymize clients that connect to our Squid proxy. Thus, IP address of the clients that connects to our Squid proxy will not be forwarded to servers that receive traffic from our Squid Proxy.</p>



<p class="wp-block-paragraph">This is done via the rules below. Add the following lines at the beginning of the Squid configuration file:</p>



<pre class="wp-block-code"><code>forwarded_for off
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all</code></pre>



<p class="wp-block-paragraph">After that, close the config file and restart your Squid proxy.</p>



<h2 class="has-vivid-cyan-blue-color has-text-color wp-block-heading">Connecting to your Squid Proxy</h2>



<p class="wp-block-paragraph">Your Squid Proxy Server is now ready, Congratulations!</p>



<p class="wp-block-paragraph">You can configure your local browser or operating system’s network settings to use your ServerStadium VM as an HTTP proxy. The settings to do this will vary depending on your OS and browser.</p>



<p class="wp-block-paragraph">You may find several official articles below to configure your Client OS or Browser to connect to the Squid Proxy:</p>



<ul class="wp-block-list">
<li><a href="https://docs.microsoft.com/en-us/windows/security/threat-protection/microsoft-defender-atp/configure-proxy-internet">Configure Proxy on Windows</a></li>
<li><a href="https://support.apple.com/en-in/guide/mac-help/mchlp2591/mac">Proxy Server Settings on macOS</a></li>
<li><a href="https://support.mozilla.org/en-US/kb/connection-settings-firefox">Connection Settings in Firefox</a></li>
</ul>
<p>The post <a href="https://serverstadium.com/knowledge-base/installing-and-configuring-squid-proxy-in-ubuntu/">Install and Configure Squid Proxy in Ubuntu</a> appeared first on <a href="https://serverstadium.com">ServerStadium</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
