This script automates the installation and configuration of a Squid proxy server on Ubuntu/Debian systems with user authentication.
- Automatic installation of required packages
- Interactive setup for port, username, and password
- IPv4 and IPv6 support
- User authentication
- Privacy settings (IP masking)
- Automatic firewall configuration
- Backup of existing configurations
- Detailed success/error reporting
- Test command generation
# Download the script
sudo wget https://gist.githubusercontent.com/drhema/31652c72c0be1bc43c7d5082bbfe84cd/raw/91b89adece7698368263eca9b95e012d43ea879d/setup-proxy.sh
# Make it executable
chmod +x setup-proxy.sh
# Run the script
sudo ./setup-proxy.sh- Ubuntu/Debian based system
- Root privileges (sudo)
- Internet connection
The script will:
- Install required packages (squid, apache2-utils, curl, net-tools)
- Prompt for configuration:
- Port number (1024-65535)
- Username (alphanumeric characters only)
- Password (minimum 6 characters)
- Configure Squid with security settings
- Set up user authentication
- Configure firewall rules
- Start and enable the Squid service
During installation, you'll need to provide:
- Proxy port number (between 1024 and 65535)
- Username (letters, numbers, underscore, hyphen only)
- Password (minimum 6 characters)
After installation, you can use the proxy with:
- Host: Your server's IP address
- Port: The port you chose during installation
- Authentication: Username and password you set up
Test the proxy using curl:
curl -v --proxy-basic --proxy-user username:password -x http://your_server_ip:port http://google.com/- Configuration file:
/etc/squid/squid.conf - Password file:
/etc/squid/passwd - Cache directory:
/var/spool/squid - Log files:
/var/log/squid/
# Start Squid
sudo systemctl start squid
# Stop Squid
sudo systemctl stop squid
# Restart Squid
sudo systemctl restart squid
# Check Status
sudo systemctl status squid- Check service status:
sudo systemctl status squid- View logs:
sudo tail -f /var/log/squid/access.log
sudo tail -f /var/log/squid/cache.log- Test configuration:
sudo squid -k parse- Check port:
sudo netstat -tulpn | grep squid- The script configures basic authentication
- All proxy connections require authentication
- The proxy port is opened in the firewall
- Password file is protected with appropriate permissions
- IP forwarding is disabled for privacy
The complete source code is available at: https://gist.github.com/drhema/31652c72c0be1bc43c7d5082bbfe84cd
For issues, please:
- Check the logs (
/var/log/squid/) - Ensure firewall rules allow the port
- Verify authentication credentials
- Check network connectivity
This script is open source and available under the MIT License.
Contributions are welcome:
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
Latest update: December 2024
- sudo apt remove squid
- sudo apt purge squid
- sudo rm -rf /etc/squid
Created by drhema (https://github.com/drhema)