Install and Configure Squid Proxy on CentOS 7 & 8
Squid is a caching and forwarding HTTP web proxy. It has a wide variety of uses, including speeding up a web server by caching repeated requests, caching web, DNS and other computer network lookups for a group of people sharing network resources, and aiding security by filtering traffic.
In this article, I’m going to show how to install & configure Squid proxy on CentOS 7 and 8. Let’s begin:
Table of Contents
Squid package is available on CentOS repository. Run this command to install Squid:
# CentOS/RHEL 8 sudo dnf install squid # CentOS/RHEL 7 sudo yum install squid
Once the installation is completed, we have start and enable Squid service:
# Enable sudo systemctl enable squid # Start sudo systemctl start squid
Now check the status:
sudo systemctl status squid
The config file located on
/etc/squid/squid.conf. Let’s take a backup before modifying:
sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.bkp
Now open the file with your favorite text editor:
sudo nano /etc/squid/squid.conf
The default Squid port is
3128. We can easily change the port:
# Default http_port 3128 # change to any port if needed
By default, Squid allows access only from localnet & localhost. We can allow specific IPs to access Squid. To do this, create this file:
sudo nano /etc/squid/allowed_ips.txt
Then enter IP address:
# Allowed IPs 192.168.45.1 192.168.21.2 # more...
Now we need to add 2 lines in the main config file:
# ... acl allowed_ips src "/etc/squid/allowed_ips.txt" # add this line # ... http_access allow localnet http_access allow localhost http_access allow allowed_ips # add this line
If you want to access Squid from any IP, then just change this:
# Change http_access deny all # To http_access allow all
Then restart Squid service:
sudo systemctl restart squid
We’re able to set authentication in Squid. We’ll use the
openssl to generate the password. The login details will be stored in
The structure of adding user:
printf "THE_USERNAME:$(openssl passwd -crypt THE_PASSWORD)\n" | sudo tee -a /etc/squid/htpasswd
Let’s add a demo user called “user1” with password “123456”:
printf "user1:$(openssl passwd -crypt 123456)\n" | sudo tee -a /etc/squid/htpasswd
After that, we have to enable the HTTP basic authentication in Squid config file:
# # add these 3 lines auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/htpasswd auth_param basic realm proxy acl authenticated proxy_auth REQUIRED # ... http_access allow localnet http_access allow localhost http_access allow authenticated # add this line
Done. Restart the Squid service:
sudo systemctl restart squid
If you are running a firewall, you’ll need to open port
3128. To do so run the following commands:
# Add port sudo firewall-cmd --permanent --add-port=3128/tcp # Reload sudo firewall-cmd --reload
Test Our Proxy
Our proxy server is ready to use. We can try to connect our proxy from any proxy client. I’m testing on Windows 10 proxy settings.
You can also set our proxy info in the browser’s proxy settings.
Google Chrome: Chrome uses default system proxy settings. Such as on Windows, chrome uses Windows proxy settings.
Firefox: Options > Network Settings > Select “Manual proxy configuration & Use this proxy server for all protocols”.
Note: Abstract API provides powerful APIs to help you enrich any user experience or automate any workflow. You can take a look at their services.Done. Our proxy server is ready to use. Thanks for reading. ?
Preview may take a few seconds to load.
Below you will find some common used markdown syntax. For a deeper dive in Markdown check out this Cheat Sheet
Bold & Italic
Bold **double asterisks**
Three back ticks and then enter your code blocks here.
# This is a Heading 1
## This is a Heading 2
### This is a Heading 3
> type a greater than sign and start typing your quote.
You can add links by adding text inside of  and the link inside of (), like so:
To add a numbered list you can simply start with a number and a ., like so:
1. The first item in my list
For an unordered list, you can add a dash -, like so:
- The start of my list
You can add images by selecting the image icon, which will upload and add an image to the editor, or you can manually add the image by adding an exclamation !, followed by the alt text inside of , and the image URL inside of (), like so:
To add a divider you can add three dashes or three asterisks:
--- or ***