mysql_auth 外部認證程式software_companion_x86 CDgroupadd squid
useradd -g squid -d /dev/null -s /bin/false squid
groupadd mysql
useradd -g mysql -s /bin/false 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
echo "bind-address = 127.0.0.1" >> /etc/my.cnf
cp /opt/sfw/mysql/share/mysql/mysql.server /etc/init.d/mysql.server
ln -s /etc/init.d/mysql.server /etc/rc3.d/S79mysql
ln -s /etc/init.d/mysql.server /etc/rc0.d/K00mysql
ln -s /etc/init.d/mysql.server /etc/rc1.d/K00mysql
ln -s /etc/init.d/mysql.server /etc/rc2.d/K00mysql
ln -s /etc/init.d/mysql.server /etc/rcS.d/K00mysql
chown root:sys /etc/init.d/mysql.server /etc/rc3.d/S79mysql
chmod 744 /etc/init.d/mysql.server /etc/rc3.d/S79mysql
mysqladmin -u root password 'strongPass'
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
http_port 192.168.0.1:3128
cache_mgr admin@example.org
error_directory /opt/sfw/squid/share/errors/Simplify_Chinese
dns_nameservers 202.99.160.68 202.99.168.8
visible_hostname proxy.example.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
cache_dir ufs /opt/sfw/squid/var/cache 1000 16 256
cache_effective_user squid
cache_effective_group squid
# 允許所有(認證由外部程式處理)
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 # 建立快取目錄結構
cat > /etc/rc3.d/S78squid <<'EOF'
#!/sbin/sh
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
EOF
chown root:sys /etc/rc3.d/S78squid
chmod 744 /etc/rc3.d/S78squid
ln -s /etc/rc3.d/S78squid /etc/rc2.d/K78squid
gzip -d mysql_auth-0.6beta.tar.gz
tar xvf mysql_auth-0.6beta.tar
cd mysql_auth-0.6beta
# 修改 Makefile 路徑
# CFLAGS=-I/opt/sfw/mysql/include -L/opt/sfw/mysql/lib/mysql
# INSTALL=/usr/ucb/install
# 安裝目標:/usr/bin/mysql_auth, /usr/local/bin/mypasswd, /etc/mysql_auth.conf
# 修改 src/define.h
# #define CONFIG_FILE "/etc/mysql_auth.conf"
# #define DEF_MYSQLD_SOCKET "/tmp/mysql.sock"
# 修改 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
mypasswd testuser 123456 # 新增
mysql_auth
testuser 123456 # 輸入帳密,回應 OK
mypasswd -d testuser # 刪除
編輯 /etc/squid/squid.conf(或 /opt/sfw/squid/etc/squid.conf),在 acl 區段後加入:
auth_param basic program /usr/bin/mysql_auth
auth_param basic realm "SQUID PROXY AUTH"
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
192.168.0.1:3128,彈窗輸入帳密。mysql_auth 需 GCC,確認 LD_LIBRARY_PATH 含 /opt/sfw/mysql/lib/mysql。127.0.0.1,外部無法直連,安全性較佳。squid:squid),否則啟動失敗。/var/log/squid/access.log、cache.log 及 MySQL 錯誤日誌。