#!/bin/bash # Update the package lists sudo apt update # Install Squid and Apache Utilities (for htpasswd) sudo apt install -y squid apache2-utils # Create a username and password for the proxy read -p "Enter the proxy username: " proxy_user sudo htpasswd -c /etc/squid/passwd $proxy_user # Backup the original Squid configuration file sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.backup # Add authentication configuration to Squid cat <<EOL | sudo tee /etc/squid/squid.conf auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd auth_param basic children 5 auth_param basic realm Proxy auth_param basic credentialsttl 2 hours acl authenticated proxy_auth REQUIRED http_access allow authenticated http_port 3128 EOL # Restart Squid to apply the changes sudo systemctl restart squid echo "HTTP proxy is set up and running on port 3128. Use the username and password you set up to access it."
Comments