6.13 How to install and configure Squid proxy server
Squid is a convenient open-source proxy server that provides caching and proxy services for HTTP, HTTPS, FTP, and other network protocols. It is widely used in corporate networks for traffic optimization, security enhancement, and access control to web resources.
The main advantages of Squid are its high performance, configuration flexibility, and the ability to significantly reduce bandwidth load through caching. This makes it an excellent choice for both small offices and large organizations.
Over the years of development, Squid has become the de facto standard for Linux systems, offering rich functionality for content filtering, user authentication, and network traffic monitoring.
Important: before installation, make sure Your system meets the minimum requirements.
- Minimum 1 GB of RAM.
- At least 10 GB of free disk space.
- Static IP address.
- Superuser (root) privileges.
Installation Procedure
Installation for Debian/Ubuntu OS:
- Update the system:
- Install Squid:
- Check status:
Installation for CentOS, AlmaLinux, RockyLinux:
- Update the system:
- Check status:
- Status check:
Basic Configuration
- Open the configuration file:
- Basic settings:
- Restart the service:
Authentication Configuration Setup
Creating Password File
- Create a user using digest authentication:
Adding subsequent users (without the -c
option):
- Set correct permissions:
Authentication Configuration Setup
Edit the /etc/squid/squid.conf
file:
Important: when setting up digest authentication.
- Make sure the path to
digest_file_auth
is correct for Your system. - Realm (
proxy
in our case) must match when creating users and in configuration. - Regularly update user passwords.
- Remove inactive users.
Additional Authentication Security Settings
- Limiting simultaneous connections:
- Speed limiting:
- Time-based access restrictions:
User Access Monitoring
To view user activity, use:
Important: when setting up authentication.
- Change passwords regularly.
- Use complex passwords.
- Remove inactive users.
- For corporate use, consider integration with LDAP or Active Directory.
Firewall Configuration
Iptables Configuration
Important: before making changes to Iptables, always save the current rules.
This will allow You to restore settings in case of an error.
To restore rules, You can use the command:
Basic Rules for Squid:
Advanced Security Rules:
Port Forwarding Configuration:
How to save firewall rules for different systems.
iptables for Debian/Ubuntu:
Use iptables-persistent to save rules.
iptables for CentOS:
Use the iptables service.
ufw for Ubuntu/Debian:
Allow the required port through UFW.
firewalld for CentOS:
Save the rule for the required port through firewalld.
Each method allows saving rules to be automatically applied after system reboot.
Automating Iptables Configuration
Create a file setup_squid_iptables.sh
, this can be done with the command: sudo nano setup_squid_iptables.sh
;
Operation Check.
To check the proxy server operation, you can use the command:
Additional Settings
Cache Configuration:
Logging Configuration:
We recommend: regularly checking logs for suspicious activity and monitoring Squid security updates.
We inform: for additional information, You can use official resources.