squid普通代理安装与配置


找了一大堆资料没有一个能讲清楚是怎么回事的。所以干脆自己写个方便大家参考。其实就是简单的浏览器代理服务器。


三台电脑设置:
第一台电脑:
eth0:192.168.23.1
第二台电脑:
eth0:192.168.23.133
eth1:200.168.10.1
第三台电脑:
eth0:200.168.10.2

第二台电脑设置如下:


[root@localhost ~]# rpm -qa | grep squid*
#检测是否已经安装过该软件
#确认没安装过后就可以安装了
[root@localhost ~]# yum -y install squid*
#删除的配置文件
[root@localhost ~]# rm -rf /etc/squid/squid.conf
[root@localhost ~]# vi /etc/squid/squid.conf
#填充以下内容
http_port 192.168.23.133:3128
visible_hostname 192.168.23.133
acl innet src 192.168.23.0/24
http_access allow innet

#启动服务
[root@localhost ~]# service squid restart
Stopping squid:                                            [FAILED]
Starting squid: .                                          [  OK  ]

squid服务启动中的任何问题都可以通过以下命令查看:
[root@localhost ~]# tail -f /var/log/squid/squid.out

检测squid端口是否已经启动:
[root@localhost ~]# netstat -tunpl | grep :3128
tcp        0      0 192.168.23.133:3128         0.0.0.0:*                   LISTEN      4530/(squid)

记得关闭防火墙
[root@localhost ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]


配置第三台电脑:


为了做实验到位,所以我们让第一台电脑访问,通过代理访问第三台电脑。
这就是为什么要把二、三台电脑设置同一网段的原因了。

[root@localhost ~]# rpm -qa | grep httpd
httpd-2.2.15-29.el6.centos.i686
httpd-tools-2.2.15-29.el6.centos.i686

启动服务:

[root@localhost ~]# service httpd restart
Stopping httpd:                                            [FAILED]
Starting httpd:                                            [  OK  ]

设置首页内容:
[root@localhost ~]# echo "<h1>hello squid</h1>">/var/www/html/index.html

记得关闭防火墙
[root@localhost ~]# service iptables stop
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Unloading modules:                               [  OK  ]

好了,配置完成。

下面开始测试:


第一台电脑打开IE浏览器,工具>Internet选项>局域网设置>设置代理服务器
内容如下:地址192.168.23.133,端口3128,保存。

键入以下地址:
http://200.168.10.2/

显示“hello squid”说明代理设置成功了。
如果无法正确访问请参考以下代码
[root@localhost ~]# tail -f /var/log/squid/squid.out

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

e421083458

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值