squid代理

代理服务器分正向代理 和 反向代理

正向代理设置

yum install squid

vim /etc/squid/squid.conf

cache_dir ufs /var/spool/squid 100 16 256    去掉该行前面注释的 并添加
cache_mem 28 MB
# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

# Add any of your own refresh_pattern entries above these.
refresh_pattern ^ftp:           1440    20%     10080
refresh_pattern ^gopher:        1440    0%      1440
refresh_pattern -i (/cgi-bin/|\?) 0     0%      0
refresh_pattern .               0       20%     4320
refresh_pattern \.(jpg|png|gif|js|css|mp3|mp4) 1440 20% 2880 ignore-reloadvisible_hostname localhost


保存退出启动服务

查看监听端口
netstat -lnp   

默认 3128
在浏览器设置代理后 可以监听网卡
tcpdump -i eth3 -nn port 3128

也可以查看缓存

cd /var/spool/squid/


可以在配置文件内修改端口
使用alc语句禁止或者允许代理访问

acl CONNECT method CONNECT
acl http proto HTTP
acl good_domain dstdomain .lishiming.net .aminglinux.com
http_access allow good_domain
http_access deny !good_domain
:wq   仅仅允许访问阿铭linux网站


squid -kcheck  检查

squid -kre        加载

 

反向代理设置

修改配置文件端口至
80

# Squid normally listens to port 3128
http_port 80 accel vhost vport
cache_peer 180.97.33.108 parent 80 0 originserver name=a
cache_peer_domain a www.baidu.com

#cache_peer 180.97.33.108 parent 80 0 originserver name=a
#cache_peer_domain a www.baidu.com


以上填写服务信息即可


解除nginx 对80端口的占用
重启squid


在本地host文件添加域名指向

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值