Site icon CentLinux

How to install Squid Proxy on CentOS 7

Share on Social Media

Learn how to install Squid Proxy on CentOS 7 with our comprehensive step-by-step guide. Enhance your network security and performance with this powerful caching proxy server. #centlinux #linux #squidproxy

What is Squid Proxy?

Squid is a caching and forwarding HTTP web proxy. Squid has a lot of features, and it is used in variety of situations such as speeding up web server by caching repeated requests, caching web and DNS lookups, filtering traffic, blocking websites, etc. It is written in C++ and distributed under GNU GPL license.

Squid Proxy is a high-performance caching proxy server for web clients, supporting HTTP, HTTPS, FTP, and other protocols. It is widely used to improve web server performance, reduce bandwidth usage, and enhance security. Here are some key features and aspects of Squid Proxy:

  1. Caching: Squid Proxy caches frequently accessed web content, reducing the load on web servers and decreasing latency for users. This can significantly improve response times and reduce bandwidth consumption.
  2. Access Control: Squid provides robust access control features, allowing administrators to define who can access the internet, what content they can access, and when they can access it. This is useful for enforcing organizational policies and preventing unauthorized use.
  3. Content Filtering: Squid can be configured to filter web content, blocking access to inappropriate or harmful websites. This is particularly useful in educational institutions and corporate environments.
  4. Logging and Monitoring: Squid generates detailed logs of web traffic, which can be analyzed to monitor usage patterns, detect anomalies, and generate reports. This helps in maintaining security and optimizing network performance.
  5. Authentication: Squid supports various authentication mechanisms, enabling it to enforce user-specific access policies. This ensures that only authorized users can access certain resources.
  6. Load Balancing: Squid can distribute web traffic across multiple servers, balancing the load and improving overall performance and reliability.
  7. Bandwidth Management: Squid allows administrators to control bandwidth usage, setting limits on data transfer rates and prioritizing certain types of traffic. This helps in managing network resources more efficiently.
  8. SSL Interception: Squid can intercept and cache SSL-encrypted traffic, enhancing its caching capabilities even for secure websites.
  9. Customizable and Extensible: Squid is highly configurable and can be customized to meet specific needs. It supports various plugins and extensions, making it adaptable to different use cases.
  10. Open Source: Squid is open-source software, meaning it is freely available and has a large community of developers and users contributing to its development and support.

Overall, Squid Proxy is a versatile and powerful tool for managing web traffic, improving performance, and enhancing security in a network environment.

Squid is considered as the most reliable content control software and has been used by many organizations since last 2 decades.

Recommended Online Training: Learn Bash Shell in Linux for Beginners

Squid Proxy Alternatives

1. Privoxy

2. Charles Proxy

3. Fiddler

4. Polipo

5. 3proxy

6. Websense (Forcepoint)

Comparison Table

Feature / ToolSquid ProxyPrivoxyCharles ProxyFiddlerPolipo3proxyWebsense (Forcepoint)
CachingYesNoNoNoYesYesNo
Load BalancingNoNoNoNoNoNoYes
Content FilteringYesYesNoNoNoNoYes
Access ControlYesYesNoNoNoYesYes
Traffic AnalysisYesBasicYesYesBasicYesYes
SSL/TLS SupportYesYesYesYesNoYesYes
Ease of SetupModerateEasyModerateEasyEasyEasyModerate
Squid Proxy Alternatives

Choosing the Right Alternative

Each tool provides unique features suited for specific tasks, so your choice will depend on your particular requirements and use cases.

Environment Specification

We have provisioned a CentOS 7 virtual machine with following specification.

Install Squid Proxy on CentOS 7

Connect with squid-proxy-01.example.com using ssh as root user.

Squid software package is available in standard yum repositories, therefore, we are installing Squid proxy using yum command.

# yum install -y squid

Enable and start Squid proxy service.

# systemctl enable --now squid.service
Created symlink from /etc/systemd/system/multi-user.target.wants/squid.service to /usr/lib/systemd/system/squid.service.

Allow Squid proxy service in CentOS 7 firewall.

# firewall-cmd --permanent --add-service=squid
success
# firewall-cmd --reload
success

Configure Squid Proxy on CentOS 7

Global configuration file for Squid web proxy is /etc/squid/squid.conf. We can customize it according to our requirement.

# vi /etc/squid/squid.conf

Add following directives therein.

dns_v4_first on

Restart Squid proxy service to load changes.

# systemctl restart squid

Configure Client’s Browser to use Squid Proxy Server

Start the client browser and add our Squid proxy in its settings.

To do this, open Internet Explorer and go to Internet Options.

Microsoft Windows – Internet Options

Go to Connections Tab and click on LAN settings.

Microsoft Windows – Internet Options – LAN

Enter Squid Proxy IP Address and Port in the above dialog box.

Click on OK to exit from Internet options.

Browse https://centlinux.com in Internet Explorer.

CentLinux website

The above website has been served through our Squid proxy server.

Configure Squid Client Authentication

We can use HTTP basic authentication to configure user based authentication for Squid proxy server.

Install httpd-tools package using yum command.

# yum install -y httpd-tools

Create the password file and add squiduser user therein.

# htpasswd -c /etc/squid/passwd squiduser
New password:
Re-type new password:
Adding password for user squiduser

Change owner of the passwd file.

# chown squid.squid /etc/squid/passwd

Now, edit Squid configuration file and add Client authentication settings.

# vi /etc/squid/squid.conf

Add following directives after the ports’ ACLs.

auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic children 5
auth_param basic realm Squid Basic Authentication
auth_param basic credentialsttl 2 hours
acl auth_users proxy_auth REQUIRED
http_access allow auth_users

Restart Squid proxy service to take changes into effect.

# systemctl restart squid

Open URL https://centlinux.com in the web browser.

Proxy Server Authentication

This time, it is prompting for the authentication.

Creating a custom Blacklist to block websites

Create a blacklist file to block websites.

# vi /etc/squid/blacklist

and add following URLs therein.

.yahoo.com
.facebook.com

Edit Squid proxy configuration file to add blacklist settings.

# vi /etc/squid/squid.conf

add following directives after the ports’ ACLs.

acl bad_urls dstdomain "/etc/squid/blacklist"
http_access deny bad_urls

Restart Squid proxy service to load changes.

# systemctl restart squid

Open URL http://www.yahoo.com in a web browser.

Squid Proxy – Website Blocked

You can see that the http://www.yahoo.com has been blocked by our Squid proxy server.

This article is strongly emphasizes on the installation and initial configuration of the Squid proxy server on CentOS 7. Therefore, if you are willing to configure some advance settings in Squid proxy then we strongly recommend you to purchase Squid Proxy Server 3.1: Beginner’s Guide (PAID LINK) by Packt Publishing.

Read Also: How to install SquidAnalyzer on CentOS 7

Final Thoughts

Installing Squid Proxy on CentOS 7 is a powerful way to enhance your network’s security and performance. With its robust caching capabilities and flexible configuration options, Squid Proxy can help you manage and optimize your web traffic effectively.

If you need professional assistance with installing and configuring Squid Proxy on any Linux Server, I offer expert services to ensure a seamless setup. Check out my Fiverr gig for more details and to get started: RHCE Linux Expert

Optimize your network with expert help. Contact me today!

Exit mobile version