你好,游客 登录 注册 搜索
背景:
阅读新闻

RHEL6.4 搭建Squid反向代理服务器

[日期:2014-05-24] 来源:Linux社区  作者:jinjianjun [字体: ]

实验需求:使用squid搭建反向代理服务器,在内网服务器192.168.100.1上启用基于域名的虚拟主机,使客户端能通过域名访问www.linuxidc.com和bbs.linuxidc.com                                                                         

                                    内网接口eth0(192.168.1.254)

 内网web服务器192.168.100.1---------- squid反向代理服务器------------- 公网客户端1.1.1.1

                                    公网接口eth1(1.1.1.254)


一.配置内网的网站服务器192.168.100.1

可以使用apache或nginx等软件搭建,本实验采用nginx搭建

1.安装nginx软件并编辑配置文件

# vim /usr/local/nginx/conf/nginx.conf

http {

  ……

    server  {

        listen  80;

        server_name  www.linuxidc.com;

          location  /  {

                  root  /www;

                  index  index.html;

        }

    }

    server  {

        listen  80;

        server_name  bbs.linuxidc.com;

        location  /  {

                  root  /bbs;

                  index  index.html;

 


        }

  }

  ……

2.制作测试网页文件

# mkdir /www

# mkdir /bbs

# echo www.linuxidc.com > /www/index.html

# echo bbs.linuxidc.com > /bbs/index.html

3.启动服务

# cd /usr/local/nginx/sbin

# ./nginx

二.配置squid反向代理服务器

1.安装软件

# yum -y install squid

2.编辑配置文件

# vim /etc/squid/squid.conf

……

# And finally deny all other access to this proxy

#http_access deny all

http_access allow all


# Squid normally listens to port 3128

http_port 80 vhost                                        //监听80端口让客户端访问

cache_peer 192.168.100.1 parent 80 0 originserver name=www

cache_peer 192.168.100.1 parent 80 0 originserver name=bbs

cache_peer_domain www www.linuxidc.com

cache_peer_domain bbs bbs.linuxidc.com

 


# We recommend you to use at least the following line.

hierarchy_stoplist cgi-bin ?

cache_mem 8 MB

minimum_object_size 0 KB

maximum_object_size 4096 KB

cache_swap_low 90

cache_swap_high 95

# Uncomment and adjust the following to add a disk cache directory.

cache_dir ufs /var/spool/squid 100 16 256

……


3.释放80端口并启动服务

# service httpd stop              //本服务器若已启动网站服务则关闭,或将其开启在别的端口

# chkconfig httpd off

# service iptables stop

# chkconfig iptables off

# service squid start

# chkconfig squid on

# netstat -tulnp | grep :80

tcp  0  0 :::80    :::*    LISTEN    3007/(squid)

三.客户端1.1.1.1测试

生产环境将www.linuxidc.com及bbs.linuxidc.com在DNS服务器内指向反向代理服务器1.1.1.254

测试环境在本机编辑hosts文件解析域名对应的IP 

# vim /etc/hosts

1.1.1.254 www.linuxidc.com

1.1.1.254 bbs.linuxidc.com


# elinks -dump http://www.linuxidc.com             

  www.linuxidc.com

# elinks -dump http://bbs.linuxidc.com

  bbs.linuxidc.com

Squid 的详细介绍请点这里
Squid 的下载地址请点这里

配置Squid代理http和rsync http://www.linuxidc.com/Linux/2013-05/84642.htm

Squid:实现高速的Web访问 http://www.linuxidc.com/Linux/2013-04/83512.htm

CentOS 6.2 编译安装Squid 配置反向代理服务器 http://www.linuxidc.com/Linux/2012-11/74529.htm

简单配置Squid代理和反向代理 http://www.linuxidc.com/Linux/2014-04/99465.htm

CentOS 6.4下DNS+Squid+Nginx+MySQL搭建高可用Web服务器 http://www.linuxidc.com/Linux/2014-04/99984.htm

本文永久更新链接地址http://www.linuxidc.com/Linux/2014-05/102220.htm

linux
相关资讯       Squid服务器  Squid反向代理服务器 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款