วันอาทิตย์ที่ 27 มีนาคม พ.ศ. 2554

Squid Proxy Authentication with Active Directory

ระบบที่ใช้ทดสอบ

Proxy Server
OS : FreeBSD 8.2 amd64
Squid Proxy version 3.1
IP address : 192.168.12.200

AD Server
OS : Microsoft Windows 2003 Server R2
IP address : 192.168.12.201

Client
OS : Microsoft Windows 7 Professional 64 bit
Web browser : Firefox 4 , IE9
IP address : 192.168.12.51

ข้อกำหนดเบื้องต้น
Domain ของระบบทดสอบคือ ad.komkit.net

ติดตั้ง AD Server ให้เรียบร้อย (ผมติดตั้งแบบมั่วสุดๆ)

ติดตั้ง FreeBSD 8.2 ตามปกติ เมื่อเสร็จแล้วจึงทำการติดตั้ง Squid Proxy ดังนี้

proxy-test# cd /usr/ports/www/squid31
proxy-test# make install

โดย Options ที่เลือกเพิ่มเติมคือ

SQUID_LDAP_AUTH

จากนั้นก็ OK อย่างเดียว รอจนกระทั่งเสร็จ

เมื่อเสร็จแล้ว เพิ่ม Configuration ของ squid ดังนี้

### ส่วนของการติดต่อกับ AD Server

auth_param basic program /usr/local/libexec/squid/squid_ldap_auth -R \
-b "dc=ad,dc=komkit,dc=net" \
-D "cn=Administrator,cn=Users,dc=ad,dc=komkit,dc=net" \
-w "Administrator-password" \
-f sAMAccountName=%s \
-h 192.168.12.201
auth_param basic children 5
auth_param basic realm KOMKIT.NET Corp.
auth_param basic credentialsttl 5 minutes

### กำหนด acl เพื่อให้มีการใช้งานการ Authen

acl adusers proxy_auth REQUIRED


### กำหนดการอนุญาตการใช้งานโดยให้ใช้การ Authen ผ่าน AD

http_access allow adusers

และทำ Configure ในส่วนอื่นๆ ตามความเหมาะ จากนั้น save configure แล้วสั่งให้ squid ทำงาน

proxy-test# /usr/local/etc/rc.d/squid start

ตรวจสอบ Log การใช้งาน

proxy-test# cat /var/log/squid/access.log
192.168.12.51 - komkit [28/Mar/2011:13:52:49 +0700] "GET http://khamsawat.blogspot.com/ HTTP/1.1" 200 18535 TCP_MISS:DIRECT

จาก log จะเห็นว่ามีการระบุ Username มาแล้ว ซึ่ง User ดังกล่าวผมกำหนดไว้ที่ AD Server

ข้อมูลอ้างอิงจาก
http://www.papercut.com/kb/Main/ConfiguringSquidProxyToAuthenticateWithActiveDirectory