码迷,mamicode.com
首页 > 其他好文 > 详细

squid 2.7 配置与安装

时间:2015-07-17 18:15:51      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:

1、准备安装包

2、准备编译环境

yum -y install gcc

3、编译安装squid

./configure \
--prefix=/data/squid \
--disable-internal-dns \
--enable-forward-log   \
--enable-follow-x-forwarded-for \
--enable-snmp \
--enable-linux-netfilter  \
--enable-http-violations \
--enable-delay-pools \
--enable-storeio=diskd,aufs,ufs,coss \
--with-coss-membuf-size=8388608 \
--with-large-files \
--enable-large-cache-files \
--with-maxfd=8192 \
--enable-removal-policies=lru,heap \
--enable-useragent-log \
--enable-referer-log  \
--enable-err-languages=Simplify_Chinese \
--enable-default-err-language=Simplify_Chinese

make && make install

4、创建缓存目录

mkdir /data/squid/var/cache
chown -R nobody.nobody /data/squid/var/cache
chown -R nobody.nobody /data/squid/var/logs

5、配置squid.conf

如果WEB服务器和反向代理服务器是两台单独的机器(一般的反向代理应该有两块网卡分别连接了内外部网络)。那么,应该修改下面的内容来设置反向代理服务。

http_port 80 # squid监听的端口
httpd_accel_host 172.16.250.250 # 内部WEB服务器的IP地址
httpd_accel_port 80 # WEB服务器的IP地址
httpd_accel_single_host on # 转发为缓冲的请求到一台单独的机器
httpd_accel_with_proxy on #
httpd_accel_uses_host_header off

如果WEB服务器和反向代理服务器是同一台机器。
那么,应该设置WEB服务器的监听端口为非80端口(比如:81端口)。要修改的内容如下:
http_port 80 # squid监听的端口
httpd_accel_host localhost # 内部WEB服务器的IP地址
httpd_accel_port 81 # WEB服务器的IP地址
httpd_accel_single_host on # 转发为缓冲的请求到一台单独的机器
httpd_accel_with_proxy on #
httpd_accel_uses_host_header off

面解释一下配置指令。

http_port 80

选项 http_port 指定squid监听HTTP请求的端口,一般都设置成80端口,这样使用户感觉不到反向代理的存在,就像访问真正的WEB服务器一样。

httpd_accel_host 172.16.250.250 和 httpd_accel_port 80

选项httpd_accel_host 和 httpd_accel_port 指定WEB服务器的IP地址和端口号,可以根据自己的WEB服务器的实际情况而定。

 

httpd_accel_single_host on

选项httpd_accel_single_host 为on 时,squid被设置成仅对单一的web服务器作反向代理。不考虑HTTP头信息,Squid转发所有的未被缓冲的页面请求到这个web服务器。如果squid需要做多个web服务器反向代理,必须将此选项设置为off,并且使用转向器或者DNS去映射请求到合适的后台WEB服务器。

httpd_accel_with_proxy on

如果希望squid既作反向代理服务器又作本地机器的上网代理,需要将httpd_accel_with_proxy 改为 on,默认情况下是off

httpd_accel_uses_host_header off

在HTTP协议1.1中,HTTP请求包括一个主机头信息,指定URL的主机名或者主机的IP地址。这个选项可以用来完成多个后台WEB服务器的反向代理功能。

 

squid 2.7 配置与安装

标签:

原文地址:http://www.cnblogs.com/hcduguo/p/4654795.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!