Skip to content

Instantly share code, notes, and snippets.

@acomagu
Created November 18, 2024 11:50
Show Gist options
  • Save acomagu/d4710fde6964b68d43aa1fb8b6d59efe to your computer and use it in GitHub Desktop.
Save acomagu/d4710fde6964b68d43aa1fb8b6d59efe to your computer and use it in GitHub Desktop.
EC2(AmazonLinux) Userdata to setup Squid server
sudo yum update -y
sudo yum install -y squid
sudo cat <<EOL > /etc/squid/squid.conf
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
auth_param basic realm proxy
auth_param basic children 5
acl HTTP_ports port 443
acl HTTP_ports port 80
acl SSL_ports port 443
acl auth proxy_auth REQUIRED
http_access deny !HTTP_ports
http_access deny CONNECT !SSL_ports
http_access deny to_localhost
http_access allow auth
http_port 3128
cache deny all
EOL
sudo echo '<YOUR .htpasswd FORMAT PAYLOAD>' > /etc/squid/passwd
sudo systemctl enable squid
sudo systemctl restart squid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment