• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

squid安装与配置

mysql 搞代码 4年前 (2022-01-09) 26次浏览 已收录 0个评论

Squid 安装 与 配置 [root@localhost ~]# yum -y install squid [root@localhost ~]# rpm -ql squid (释放文件) /etc/squid/squid.conf /etc/squid/msntauth.conf.default ( 配置 文件模板) /var/log/squid (日志目录) /var/spool/squid (缓存目录)

Squid安装配置

[root@localhost ~]# yum -y install squid

[root@localhost ~]# rpm -ql squid(释放文件)

/etc/squid/squid.conf

/etc/squid/msntauth.conf.default配置文件模板)

/var/log/squid(日志目录)

/var/spool/squid(缓存目录)

[root@localhost ~]# vim /etc/squid/squid.conf(常用基本配置

http_port 3128

cache_mem 64 MB 内存占用量

maximum_object_size 4096 KB(最大缓存)

access_log /var/log/squid/access.log squid

visible_hostname proxy.openlab.com(代理服务器主机名)

dns_testnames http://www.google.com http://www.163.com(测试DNS

cache_dir ufs /var/spool/squid 100 16 256100M,)

1.squid 服务器实现基本代理

squid服务器

eth0 200.200.200.10

eth1 192.168.10.8

WEB服务器

eth0 200.200.200.100

[root@www ~]# iptables -P INPUT DROP -P默认规则)

[root@localhost ~]# iptables -I INPUT -p tcp –dport 22 -j ACCEPT

[root@localhost ~]# iptables -I INPUT -p tcp –dport 80 -j ACCEPT

squid服务器

[root@localhost ~]# service squid restart(启动服务,无需配置

Stopping squid: ………….. [ OK ]

Starting squid: . [ OK ]

[root@localhost ~]# vim /etc/squid/squid.conf

cache_dir ufs /var/spool/squid 100 16 256(去掉前面#

reply_body_max_size 10 MB(不允许下载大于10M附件,此行需添加)

acl RealFile urlpath_regex -i \.mp3$(添加一条acl

http_access deny all

2.透明代理

Squid服务器

Eth0 200.200.200.10 eth1 192.168.10.8

[root@localhost ~]# vim /etc/squid/squid.conf

http_port 192.168.10.8:3128 transparent

[root@localhost ~]#iptables -t nat -I PREROUTING -i eth1 -s 192.168.10.0/24 -p tcp –dport 80 -j REDIRECT –to-ports 3128

[root@localhost ~]# service iptables save

开启路由转发

[root@localhost ~]# vim /etc/sysctl.conf

net.ipv4.ip_forward = 0

[root@localhost ~]# sysctl -p

配置nat

[root@localhost ~]# iptables -t nat -I POSTROUTING -s 192.168.10.0/24 -o eth1 -j SNAT –to-source 200.200.200.10

WEB服务器

Eth0 200.200.200.100

[root@localhost ~]# iptables -L –line-numbers

Chain INPUT (policy DROP)

num target prot opt source destination

1 ACCEPT tcp anywhere anywhere tcp dpt:http

2 ACCEPT tcp anywhere anywhere tcp dpt:ssh

测试

3.Squid反向代理

[root@localhost ~]# vim /etc/squid/squid.conf

http_port 218.29.30.31:80 vhost vhost虚拟主机,80因为h本文来源gaodai#ma#com搞@代~码^网+ttp默认是80,所以代理端口写成80

cache_peer 192.168.2.11 parent 80 0 originserver weight=5 max-conn=30originserver代表真实serverweight权重,越大越优先)

cache_peer 192.168.2.12 parent 80 0 originserver weight=5 max-conn=30

cache_peer 192.168.2.13 parent 80 0 originserver weight=5 max-conn=30

cache_peer 192.168.2.14 parent 80 0 originserver weight=1 max-conn=8

http_access allow all(允许外部所有访问)

[root@localhost ~]# service squid restart

无心


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:squid安装与配置
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址