Advertisement
mashiahd

Squid Server Install

Nov 13th, 2023
1,699
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.93 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Update the package lists
  4. sudo apt update
  5.  
  6. # Install Squid and Apache Utilities (for htpasswd)
  7. sudo apt install -y squid apache2-utils
  8.  
  9. # Create a username and password for the proxy
  10. read -p "Enter the proxy username: " proxy_user
  11. sudo htpasswd -c /etc/squid/passwd $proxy_user
  12.  
  13. # Backup the original Squid configuration file
  14. sudo cp /etc/squid/squid.conf /etc/squid/squid.conf.backup
  15.  
  16. # Add authentication configuration to Squid
  17. cat <<EOL | sudo tee /etc/squid/squid.conf
  18. auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd
  19. auth_param basic children 5
  20. auth_param basic realm Proxy
  21. auth_param basic credentialsttl 2 hours
  22. acl authenticated proxy_auth REQUIRED
  23. http_access allow authenticated
  24. http_port 3128
  25. EOL
  26.  
  27. # Restart Squid to apply the changes
  28. sudo systemctl restart squid
  29.  
  30. echo "HTTP proxy is set up and running on port 3128. Use the username and password you set up to access it."
  31.  
Tags: squid
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement