China Open source community
站内导航:
站内排行前50热点文章

精华文章  GDB调试精粹及使用实例
普通文章  STL中map用法详解
精华文章  负载均衡软件比较(Hapr...
普通文章  头文件的重复引用
普通文章  递归函数的调用过程
普通文章  TCP三次握手/四次挥手详解
普通文章  贪心策略的理论基础——...
普通文章  BMH算法原理与实现(模...
普通文章  排列组合与回溯算法
普通文章  DP动态规划
精华文章  Android线程模型
普通文章  Linux socket编程之套接字
普通文章  Linux内核中的红黑树
精华文章  linux下使用minicom的几...
普通文章  Java开源Html解析类库
精华文章  enum类型的本质
普通文章  memcached server LRU ...
普通文章  linux设置环境变量的方法
普通文章  android核心模块及相关...
普通文章  linux源代码包(.tar.g...
普通文章  L.A.M.P配置过程
普通文章  在ubuntu9.10下安装QT4...
普通文章  C/C++程序员常见面试题...
普通文章  gcc编译过程概述
普通文章  python的memcache和jso...
普通文章  应用程序二进制接口---ABI
普通文章  linux内核编译问题
普通文章  Java多线程实现简单实例
普通文章  Python程序员常用的IDE...
普通文章  brk和sbrk详述
普通文章  优化C语言代码(程序员必...
普通文章  python非贪婪,多行匹配...
普通文章  函数指针传递和全局指针...
普通文章  Unix操作系统的历史演变
普通文章  网络编程之C10K问题
普通文章  发行版发布:CentOS 5.4
普通文章  在windows中构建gtk开发...
普通文章  i++循环与i--循环的执行...
普通文章  关于Qvariant类--万能的...
普通文章  Debian sudo 设置
普通文章  busybox1.15.x 交叉编译
普通文章  关于僵死进程zombie
普通文章  递归思想的妙用
普通文章  判断链表是否存在环并找...
普通文章  Android Porting Exper...
普通文章  关于/etc/bashrc和$HOM...
普通文章  [翻译]Django初窥
普通文章  Python list的排序
普通文章  Django实现大数据量分页...
普通文章  Debug方式取代printf满...

 
 
 
当前位置: 首页 >> 应用软件 >> 网络相关 >> Squid 安装配置指南
 
 

Squid 安装配置指南

作者:wangking78      来源:cublog     发表时间:2006-07-24     浏览次数:      字号:    

红色的部分是手工输入的命令,绿色的是文件的配置.

 

1.安装linux系统,选择自定义安装,选择开发工具包,webSERVER服务,去掉squid,安装的时候把SELINUX选成DISABLE

 

你也可以不用做以下的步骤,用我提供的脚本安装一下的一些配置!!!setup.tar.bz2拷贝到

/root目录下,然后用

tar –jxvf setup.tar.bz2

cd ./setup

sh ./setup

这三个命令就可以完成下面的配置了.安装完毕后系统会重新启动,启动后进入系统,配置ipmacfile文件(ipmac地址绑定文件)和初始化你用户和密码(具体请看服务器使用说明)

 

 

2.下载源代码并解压

 

cd /usr/src

wget -c http://www.squid-cache.org/Versions/v2/2.5/squid-2.5.STABLE14.tar.gz

tar -zxvf squid-2.5.STABLE14.tar.gz

 

 

3.安装Squid Proxy Server

 

cd /usr/src/squid-2.5.STABLE14

 

./configure --prefix=/usr/local/squid --sysconfdir=/etc/squid --bindir=/usr/bin --sbindir=/usr/sbin --mandir=/usr/share/man --enable-gnuregex --enable-carp --enable-async-io=80 --enable-removal-policies=heap,lru --enable-icmp --enable-delay-pools --enable-useragent-log --enable-referer-log --enable-kill-parent-hack --enable-snmp --enable-arp-acl --enable-htcp --enable-cache-digests --enable-default-err-language=Simplify_Chinese --enable-err-languages="Simplify_Chinese" --enable-poll --enable-linux-netfilter --disable-ident-lookups --enable-underscores --enable-auth="basic" --enable-basic-auth-helpers="NCSA" --enable-external-acl-helpers="ip_user" --enable-x-accelerator-vary

 

make && make install

 

 

4.设置squid.conf

 

cd

mv /etc/squid/squid.conf /etc/squid/squid.conf.bak

vi /etc/squid/squid.conf  #在按下i

==============================/etc/squid/squid.conf=========================

http_port 100.100.100.1:808

cache_mem 64 MB

dns_nameservers 202.98.0.68 202.98.5.68

visible_hostname 100.100.100.1

cache_mgr murong@ccds.gov.cn

cache_dir aufs /usr/local/squid/var/cache 25000 16 256

error_directory /usr/local/squid/share/errors/Simplify_Chinese

emulate_httpd_log on

cache_store_log none

logfile_rotate 1

hierarchy_stoplist cgi-bin ?

hierarchy_stoplist -i ^https:\\ ?

acl QUERY urlpath_regex -i cgi-bin \? \.asp \.php \.jsp \.cgi

acl denyssl urlpath_regex -i ^https:\\

no_cache deny QUERY

no_cache deny denyssl

auth_param basic program /usr/local/squid/libexec/ncsa_auth /etc/squid/passwd.sq

auth_param basic children 10

auth_param basic realm proxy.linuxserver.com

auth_param basic credentialsttl 2 hours

auth_param basic casesensitive off

refresh_pattern ^ftp:             1440       20% 10080

refresh_pattern ^gopher: 1440       0%  1440

refresh_pattern .            0     20% 4320

acl all src 0.0.0.0/0.0.0.0

acl OverConnLimit maxconn 5

acl auth_user proxy_auth REQUIRED

#acl macaddress arp 00:16:36:05:a6:54

acl manager proto cache_object

acl localhost src 127.0.0.1/255.255.255.255

acl to_localhost dst 127.0.0.0/8

acl SSL_ports port 443 563

acl Safe_ports port 80           # http

acl Safe_ports port 21           # ftp

acl Safe_ports port 443 563   # https, snews

acl Safe_ports port 70           # gopher

acl Safe_ports port 210         # wais

acl Safe_ports port 1025-65535    # unregistered ports

acl Safe_ports port 280         # http-mgmt

acl Safe_ports port 488         # gss-http

acl Safe_ports port 591         # filemaker

acl Safe_ports port 777         # multiling http

acl CONNECT method CONNECT

http_access allow auth_user

http_access deny OverConnLimit

#http_access allow macaddress

http_access allow manager localhost

http_access deny manager

http_access deny !Safe_ports

http_access deny CONNECT !SSL_ports

http_access deny all

http_reply_access allow all

icp_access allow all

coredump_dir /usr/local/squid/var/cache

===============================脚本结束================================

 

 

5.初始化cache目录和启动squid

 

cd

htpasswd -cb /etc/squid/passwd.sq proxy proxy

chmod 666 /etc/squid/passwd.sq

mkdir -p /usr/local/squid/var/cache

cd /usr/local/squid/var

chown -R nobody.nobody cache logs

squid -z

squid start

squid -k parse        #检查配置是否有错误,没有任何输出,证明配置基本是正确的!!!

squid -zX               #可以加一个X参数,看看初始化具体的项目.  

如果因为DNS无法启动squid,可以用下面的命令启动squid

squid -D

 

 

6.安装squid密码修改工具

 

修改/etc/httpd/conf/httpd.conf的内容,"AddDefaultCharset" 设置成 GB2312,WEB显示中文.

cd /usr/src

vi /var/www/html/index.html

 

============================/var/www/html/index.html=======================<a href="../cgi-bin/chpasswd.cgi">请单击这里修改您的用户密码</a>

===================================配置结束============================

 

wget -c http://jaist.dl.sourceforge.net/sourceforge/orsochpasswd/chpasswd-2.2.3.tar.gz

wget -c http://sarg.sourceforge.net/htoi.patch

tar -zxvf chpasswd-2.2.3.tar.gz

cd /usr/src/chpasswd-2.2.3

patch -p0 < ../htoi.patch

./configure --enable-language=Chinese --enable-cgidir=/var/www/cgi-bin

make && make install

vi /usr/local/etc/chpasswd/chpasswd.conf

 

=================/usr/local/etc/chpasswd/chpasswd.conf=========================

password_file /etc/squid/passwd.sq

=================================脚本结束==============================

 

 

7.防火墙设置及IP地址与MAC地址绑定

 

touch /usr /sbin/firewall

chmod u+x /usr/sbin/firewall

vi /usr/sbin/firewall

 

===============================/usr/sbin/firewall===========================

#!/bin/sh

 

UPLINK="eth0"

LANLINK="eth1"

INTERFACES="lo eth0 eth1"

 

case "$@" in

start)

echo -n "Starting firewall..."

iptables -F

iptables -X

iptables -Z

iptables -t nat -F

iptables -t nat -X

iptables -t nat -Z

iptables -t mangle -F

iptables -t mangle -X

iptables -t mangle -Z

iptables -P INPUT DROP

 

iptables -A INPUT -i lo -j ACCEPT

iptables -A OUTPUT -o lo -j ACCEPT

 

iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

 

#enable public access to certain services

iptables -A INPUT -p tcp --dport 22 -m state --state NEW -j ACCEPT

iptables -A INPUT -p tcp --dport 80 -i ! ${UPLINK} -m state --state NEW -j ACCEPT

iptables -A INPUT -p tcp -i ${UPLINK} -j REJECT --reject-with tcp-reset

 

while read ipaddr macaddr

do

iptables -A INPUT -s ${ipaddr} -m mac --mac-source ${macaddr} -j ACCEPT

done < /etc/ipmacfile

 

#enable system-log

#iptables -A INPUT -j LOG --log-prefix "bad input:"

#iptables -A INPUT -p udp -i ${UPLINK} -j REJECT --reject-with icmp-port-unreachable

 

#explicitly disable ECN

if [ -e /proc/sys/net/ipv4/tcp_ecn ]

then

echo 0 > /proc/sys/net/ipv4/tcp_ecn

fi

 

#disable spoofing on all interfaces

for x in ${INTERFACES}

do

echo 1 > /proc/sys/net/ipv4/conf/${x}/rp_filter

done

 

echo "OK!"

exit 0

;;

stop)

echo -n "Stopping firewall..."

iptables -F

iptables -X

iptables -Z

iptables -t nat -F

iptables -t nat -X

iptables -t nat -Z

iptables -t mangle -F

iptables -t mangle -X

iptables -t mangle -Z

iptables -P INPUT ACCEPT

iptables -P OUTPUT ACCEPT

iptables -P FORWARD ACCEPT

iptables -t nat -P POSTROUTING ACCEPT

iptables -t nat -P PREROUTING ACCEPT

iptables -t nat -P OUTPUT ACCEPT

echo "OK!"

exit 0

;;

restart)

$0 stop

$0 start

 

;;

show)

clear

echo ">------------------------------------------------------"

iptables -nvL

echo ">------------------------------------------------------"

iptables -t nat -nvL

exit 0

;;

*)

echo "Usage: $0 {start|stop|restart|show}"

exit 1

esac

=================================脚本结束==============================

:

建立IP地址与MAC地址对应关系表

touch /etc/ipmacfile

vi /etc/ipmacfile

ipmacfile文件格式

100.100.100.100 00:16:36:05:a6:54

100.100.100.101 00:16:36:05:a6:53

 

[1] [2]

编辑 webmaster

 
 
 
评论
 
 
发表
 
姓名: QQ:
性别: MSN:
E-mail: 主页:
评分: 1 2 3 4 5
评论内容:
验证码:
  
  • 请遵守《互联网电子公告服务管理规定》及中华人民共和国其他各项有关法律法规。
  • 严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
  • 用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表网友个人观点,与本网站立场无关。
  •  
    中国源码网 - www.YuanMa.org - 中国 开放源代码+编程 社区