Home > Database > Mysql Tutorial > body text

squid安装与配置

WBOY
Release: 2016-06-07 15:10:50
Original
1726 people have browsed it

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 www.google.com 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因为http默认是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

 

无心

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template