程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> 關於MYSQL數據庫 >> 用戶認證功能的SQUID代理服務器

用戶認證功能的SQUID代理服務器

編輯:關於MYSQL數據庫

SQUID和MYSQL的安裝采用了SUN發布的二進制安裝包,它在software_companion_x86 CD中可以找到;MySQL_AUTH用GOOGLE搜索就可以找到。

一、安裝配置SQUID+MySQL

1.建立用戶和組
# groupadd squid
# useradd -g squid -d /dev/null -s /bin/false squid
# groupadd MySQL
# useradd -g mysql -s /bin/false MySQL

2. 安裝MySQL

# mount –F hsfs –o ro /dev/dsk/c1t0d0p0 /cdrom
# cd /cdrom/components/i386/Packages
# pkgadd -d ./ -s /var/spool/pkg SFWMySQL SFWgcmn
# pkgadd SFWgcmn SFWMySQL

# chown -R root /opt/sfw/MySQL
# chgrp -R mysql /opt/sfw/MySQL
# chown -R mysql /opt/sfw/MySQL/var
# /opt/sfw/mysql/bin/MySQL_install_db
# /opt/sfw/mysql/bin/MySQLd_safe &

# cp /opt/sfw/mysql/share/MySQL/my-medium.cnf /etc/my.cnf
# vi /etc/my.cnf
bind-address = 127.0.0.1


設置啟動腳本:

# cp /opt/sfw/mysql/share/mysql/mysql.server /etc/init.d/MySQL.server
# ln /etc/init.d/mysql.server /etc/rc3.d/S79MySQL
# ln /etc/init.d/mysql.server /etc/rc0.d/K00MySQL
# ln /etc/init.d/mysql.server /etc/rc1.d/K00MySQL
# ln /etc/init.d/mysql.server /etc/rc2.d/K00MySQL
# ln /etc/init.d/mysql.server /etc/rcS.d/K00MySQL
# chown root:sys /etc/init.d/mysql.server /etc/rc3.d/S79MySQL
# chmod 0744 /etc/init.d/mysql.server /etc/rc3.d/S79MySQL

設置ROOT密碼:
# MySQLadmin -u root passWord llzQQ

3.安裝SQUID

# pkgadd -d ./ -s /var/spool/pkg SFWsquid
# pkgadd SFWsquid
# cd /opt/sfw/squid/etc
# cp squid.conf.default squid.conf
# cp mime.conf.default mime.conf

4.配置SQUID.CONF

http_port 192.168.0.1:3128
cache_mgr [email protected]
error_directory /opt/sfw/squid/share/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_port 80
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_swap_low 85
cache_swap_high 90
cache_dir ufs /opt/sfw/squid/var/cache
cache_effective_user squid
cache_effective_group squid

#http_Access allow manager localhost
#http_Access allow 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
miss_Access allow all
--------------------------------------------------------
# chown –R squid:squid /opt/sfw/squid/var
# /opt/sfw/squid/sbin/squid -z


5. SQUID啟動腳本

# vi /etc/rc3.d/S78squid
====================== S78squid =====================
#!/sbin/sh
#
# Copyright (c) 2004 by llzQQ, Inc
# [email protected]
# All rights reserved.
#
#ident '@(#)squid 1.1 04/05/24 SMI'

case '$1' in
start)
/opt/sfw/squid/sbin/squid -s
;;
stop)
/opt/sfw/squid/sbin/squid -k shutdown
pkill squid
;;
*)
echo 'Usage: $0 { start | stop }'
exit 1
;;
esac
exit 0
====================== S78squid =====================
# chown root:sys /etc/rc3.d/S78squid
# chmod 744 /etc/rc3.d/S78squid
# ln -s /etc/rc3.d/S78squid /etc/rc2.d/K78squid

二、 安裝MySQL_AUTH

# gzip -d MySQL_auth-0.6beta.tar.gz
# tar vxf MySQL_auth-0.6beta.tar
# cd MySQL_auth-0.6beta


Makefile中需要修改的內容如下:

# vi Makefile

CFLAGS = -I/opt/sfw/mysql/include -L/opt/sfw/mysql/lib/MySQL
INSTALL = /usr/ucb/install
$(INSTALL) -o root -g sys -m 700 mypasswd /usr/local/bin/mypasswd
$(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中需要修改的內容如下:

# vi +5 src/define.h
#define CONFIG_FILE '/etc/MySQL_auth.conf'
#define DEF_MYSQLD_SOCKET '/tmp/MySQL.sock'


src/MySQL_auth.conf中需要修改的內容如下:

# vi src/MySQL_auth.conf
mysqld_socket /tmp/MySQL.sock
# /usr/ccs/bin/make
# /usr/ccs/bin/make install


創建用戶數據庫:
# cd scripts
# MySQL -u root -p****** < create_script

測試MySQL_AUTH

1.添加一個測試用戶
# mypasswd llzQQ 123456
PassWord record ADDED succesfully.

2.驗證剛才建立的用戶
# MySQL_auth
llzQQ 123456
0K

3.刪除一個已經建立的用戶用這個命令
# mypasswd –d username

三、在SQUID.CONF中增加MySQL_AUTH認證部分
# vi /etc/squid/squid.conf

添加下面的代碼到SQUID.CONF中“TAG: acl”一節的後面

auth_param basic program /usr/bin/MySQL_auth
auth_param basic realm LLZQQ’S 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

在下載軟件FlashGET的代理服務器設置中填寫SQUID服務器的IP、端口、用戶和密碼:
192.168.0.1:3218
user:llzQQ
passwd:123456

五、注意事項

在進行以上安裝前要先安裝GCC否則不能編譯MYSQL_AUTH,另外在添加用戶前需要設置ROOT用戶的LD_LIBRARY_PATH變量中有這個路徑:/opt/sfw/mysql/lib/MySQL

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved