squid-4.17安装
tar zxf squid-4.17.tar.gz -C /usr/src/
./configure --prefix=/usr/local/squid --sysconfdir=/etc --enable-linux-netfilter --enable-async-io=240 --enable-default-err-language=Simplify_Chinese --disable-poll --enable-epoll --enable-gnuregex
make && make install
ln -s /usr/local/squid/sbin/* /usr/sbin/
useradd -M -s /sbin/nologin squid
chown -R squid:squid /usr/local/squid/var/
修改配置文件
cache_effective_user squid
cache_effective_group squid
该版本源码包中有服务脚本
cp /usr/src/squid-4.17/tools/systemd/squid.service /lib/systemd/system/
服务
[Unit]
Description=Squid Web Proxy Server
Documentation=man:squid(8)
After=network.target network-online.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/sbin/squid
ExecStop=/usr/local/sbin/squid -k kill
ExecReload=/usr/local/sbin/squid -k reconfigure
KillMode=mixed
NotifyAccess=all
[Install]
WantedBy=multi-user.target
linux客户机的命令行界面中使用代理服务器
vim /etc/profile
HTTP_PROXY=http://192.168.107.159:3128
HTTPS_PROXY=http://192.168.107.159:3128
FTP_PROXY=http://192.168.107.159:3128
NO_PROXY=192.168.1.,192.168.4.
export HTTP_PROXY HTTPS_PROXY FTP_PROXY NO_PROXY
透明模式
firewall-cmd --change-zone=ens33 --zone=external
firewall-cmd --zone=internal --change-zone=ens37
firewall-cmd --zone=external --add-service=http
firewall-cmd --zone=external --add-service=https
firewall-cmd --zone=external --add-service=3128/tcp
firewall-cmd --zone=external --add-port=3128/tcp
firewall-cmd --direct --add-rule ipv4 nat PREROUTING 0 -i ens33 -p tcp --dport 80 -j REDIRECT --to-ports 3128
firewall-cmd --direct --add-rule ipv4 nat PREROUTING 1 -i ens33 -p tcp --dport 443 -j REDIRECT --to-ports 3128
firewall-cmd --runtime-to-permanent