安装说明:如果你的系统已经安装了SQUID,要先卸载了然后按照本文中的步骤重新安装SQUID。另外如果以前用的是IPTABLES+SQUID做的透明代理,仍然要在浏览器中进行代理服务器设置,否则SQUID不能使用mysql认证,关于MYSQL_AUTH的版本是这样的,0.5版的我实验了很久总不能成功,所以我用了0.6beta版的MYSQL_AUTH。
一、安装SQUID和MYSQL-SERVER
1.建立用户和组
[root@home root]# groupadd squid
[root@home root]# adduser -g squid -d /dev/null -s
/sbin/nologin squid
2. 安装
[root@home root]# rpm –ivh mysql-server-3.23.58-1.9.i386.rpm
[root@home root]# rpm -ivh squid-2.5.STABLE3-3.3E.i386.rpm
设置MYSQL的ROOT管理密码:
[root@home root]# mysqladmin –u root passWord ******
设置MSYQL和SQUID开机启动:
[root@home root]# chkconfig mysqld on
[root@home root]# chkconfig squid on
3.配置SQUID.CONF
--------------------------------------------------------
http_port 3128
cache_mgr
[email protected]
error_Directory /usr/share/squid/errors/Simplify_Chinese
dns_nameservers 202.99.160.68 202.99.168.8
visible_hostname nero.3322.org
httpd_accel_uses_host_header on
httpd_accel_host virtual
httpd_accel_with_proxy on
cache_mem 20 MB
maximum_object_size 4096 KB
minimum_object_size 0 KB
maximum_object_size_in_memory 30 KB
minimum_object_size_in_memory 0 KB
cache_dir ufs /tmp 100 16 256
cache_swap_low 85
cache_swap_high 90
httpd_accel_port 80
#http_Access deny all
--------------------------------------------------------
4.启动SQUID和MYSQL
[root@home root]# service mysqld start
[root@home root]# service squid start
二、 译安装MYSQL_AUTH-0.6
[root@home root]# tar xzpf mysql_auth-0.6beta.tar.gz
[root@home root]# cd mysql_auth-0.6beta
修改Makefile中的内容如下:
[1] [2] [3] 下一页
[root@home mysql_auth-0.6beta]# vi Makefile
CFLAGS = -I/usr/include/mysql -L/usr/lib/mysql
$(INSTALL) -o squid -g squid -m 755 mysql_auth /usr/bin/mysql_auth
$(INSTALL) -o squid -g squid -m 600 $(CONF) /etc/mysql_auth.conf
$(INSTALL) -o squid -g squid -m 600 $(CONF) /etc/mysql_auth.conf.default
修改src/define.h中的内容如下:
[root@home mysql_auth-0.6beta]# vi +5 src/define.h
#define CONFIG_FILE "/etc/mysql_auth.conf"
#define DEF_MYSQLD_SOCKET "/var/lib/mysql/mysql.sock"
修改src/mysql_auth.conf中的内容如下:
[root@home mysql_auth-0.6beta]# vi src/mysql_auth.conf
mysqld_socket /var/lib/mysql/mysql.sock
[root@home mysql_auth-0.6beta]# make
[root@home mysql_auth-0.6beta]# make install
创建用户数据库:
[root@home mysql_auth-0.6beta]# cd scripts
[root@home scripts]# mysql -u root –p****** < create_script
三、 测试MYSQL_AUTH
1.添加一个测试用户
[root@home mysql_auth-0.6beta]# mypasswd test 123456
Password record ADDED sUCcesfully.
2.验证刚才建立的用户
[root@home mysql_auth-0.6beta]# mysql_auth test
test 123456
0K
3.删除一个已经建立的用户用这个命令
[root@home mysql_auth-0.6beta]# mypasswd –d username
Password record DELETED succesfully.
四、在SQUID.CONF中增加MYSQL_AUTH认证
[root@home mysql_auth-0.6beta]# vi /etc/squid/squid.conf
添加下面的代码到SQUID.CONF中“TAG: acl”一节的后面
auth_param basic program /usr/bin/mysql_auth
auth_param basic realm Squid caching server
auth_param basic children 5
auth_param basic credentialsttl 2 hours
acl password proxy_auth REQUIRED
http_access allow password
authenticate_ip_ttl 2 hours
http_access deny all
五、客户端设置
在你浏览器的代理服务器设置中填写SQUID服务器的IP和端口:
192.168.0.1:3218
在你下载软件的代理服务器设置中填写SQUID服务器的IP和端口:
192.168.0.1:3218
六、一个简单的IPTABLES脚本
eth0:to lan
eth1:to adsl-modem
-------------------------------------------------------------------
#!/bin/bash
eXPort PATH=/sbin:/usr/sbin:/bin:/usr/bin
echo 1 >/proc/sys/net/ipv4/ip_forward
iptables -F
iptables -X
iptables -Z
## Allow forwarding through the internal interface
iptables -A FORWARD -i eth0 -j ACCEPT
iptables -A FORWARD -o eth0 -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
## Do masquerading through ppp0
上一页 [1] [2] [3] 下一页
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
## SQUID
iptables -t nat -A PREROUTING -i eth0 -p tcp -s 0/0 --dport 80 -j REDIRECT --to-ports 3128
## HTTP
iptables -A INPUT -i ppp0 -p tcp -s 0/0 --sport 80 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -s 0/0 --sport 443 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -d 0/0 --dport 80 -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -d 0/0 --dport 443 -j ACCEPT
## DNS
iptables -A INPUT -i ppp0 -p udp -s 0/0 --sport 53 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -i ppp0 -p udp -d 0/0 --dport 53 -j ACCEPT
## Anything else not allowed
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -j DROP
(出处:http://www.sheup.com)
上一页 [1] [2] [3]
iptables -A INPUT -i ppp0 -p tcp -s 0/0 --sport 443 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -d 0/0 --dport 80 -j ACCEPT
iptables -A INPUT -i ppp0 -p tcp -d 0/0 --dport 443 -j ACCEPT
## DNS
iptables -A INPUT -i ppp0 -p udp -s 0/0 --sport 53 -m state --state ESTABLISHED -j ACCEPT
iptables -A INPUT -i ppp0 -p udp -d 0/0 --dport 53 -j ACCEPT
## Anything else not allowed
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -i ppp0 -j DROP
(出处:http://www.sheup.com/)
上一页 [1] [2] [3] [4]