安装和配置squid
安装
sudo yum install squid -y
修改配置
sudo vi /etc/squid/squid.conf 找到以下几行并注释 http_access deny CONNECT !SSL_ports http_access deny !Safe_ports http_access deny to_localhost
启动
sudo systemctl start squid
重启
sudo systemctl restart squid
查看日志
tail -f /var/log/squid/access.log

给squid加密
生成密码
用openssl来生成密码,并且附加username:password对到文件/etc/squid/htpasswd文件中,并且显示出来。
如果你还没有安装openssl,可使用如下语法安装:
sudo yum install openssl openssl-devel
生成用户名密码的语法如下:
printf "USERNAME:$(openssl passwd PASSWORD)\n" | sudo tee -a /etc/squid/htpasswd
例如:创建一个用户名称为wangxch,并且密码为Pz$lPk76,你将要运行:
printf "wangxch:$(openssl passwd -crypt 'Pz$lPk76')\n" | sudo tee -a /etc/squid/htpasswd
在 /etc/squid/squid.conf尾部添加如下:
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/htpasswd auth_param basic realm proxy acl authenticated proxy_auth REQUIRED # ... http_access allow localnet http_access allow localhost http_access allow authenticated # And finally deny all other access to this proxy http_access deny all
重启squid
sudo systemctl restart squid