Squid反向代理

通过配置代理服务器,可以实现以下目标:

1.代理服务器可以将远程的web服务器缓存到本地,利用缓存机制可以提高网站的响应速度

2. 远程Web服务器对客户端用户是透明的。

Squid反向代理


work NAT 29.147 \ /etc/squid/squid_yw002.conf 使用浏览器 yw002 反向代理实验 \
tpl01 NAT + NAT(wmnet5) 29.150 + 117.128 Squid(yum) \ \ yw002 反向代理实验 squid-3.1.23-24.el6.x86_64
tpl02 NAT(wmnet5) 117. 130 httpd(yum) \ \ yw002 反向代理实验 httpd-2.2.15-60.el6.centos.6.x86_64


说明: web服务器可以是多台

步骤一: 构建web服务器 (tpl02)

    1. yum -y install httpd

    rpm -q httpd

    service httpd restart ; chkconfig httpd on

    netstat -anptu | grep httpd

 2. 为网站建立测试文件

     /var/www/html

 步骤二:部署Squid代理服务器(tpl01)

     1. 使用yum 安装squid软件包:

      yum -y install squid

      rpm -q squid

   2. 修改/etc/squid/squid.conf 配置文件:

     http_port 80 vhost   //注意vhost 一定要有

     visible_hostname tpl01.liang.com

     cache_peer 192.168.117.130 parent 80 0 originserver  //可以多条,每条对应一个web服务器

     cache_dir ufs /var/spool/squid  200  16 128

     http_access allow localnet   

   3. service squid restart; chkconfig squid on

      netstat -anptu | grep 80

   步骤三: hosts 

     1.  cat /etc/hosts  (work)

        192.168.29.150 web.liang.com

    2. cat /etc/hosts (tpl02)

       127.0.0.1 web.liang.com

    步骤四: 测试

      在客户端 : firefox http://web.liang.com