1/25/2017

Proxy : Ubuntu 16.04 Squid

Proxy : Ubuntu 16.04 Squid
- ติดต้้่ง 16.04 Server set apt.conf update upgrade ให้เรียบร้อย
  1. apt nano /etc/apt/apt.conf

Acquire::http { Proxy "http://192.168.2.16:9999"; };
  1. apt-get update
  1. apt-get upgrade


- Generate locale perl: warning
  1. locale-gen en_US en_US.UTF-8 th_TH th_TH.UTF-8


- ติดตั้ง โปรแกรม
  1. apt-get install squid3
  1. apt-get install apache2


- join domain
  1. apt-get install krb5-user samba winbind


- แก้ไฟล์ krb5.conf
  1. nano /etc/krb5.conf

แทนที่ทั้งหมด
  1. [logging]
  2. default = FILE:/var/log/krb5.log
  3. [libdefaults]
  4. ticket_lifetime = 24000
  5. clock_skew = 300
  6. default_realm = SCI.COM
  7. krb4_config = /etc/krb.conf
  8. krb4_realms = /etc/krb.realms
  9. kdc_timesync = 1
  10. ccache_type = 4
  11. forwardable = true
  12. proxiable = true
  13. default_tgs_enctypes = aes256-cts arcfour-hmac-md5 des3-hmac-sha1 des-cbc-crc des-cbc-md5
  14. default_tkt_enctypes = aes256-cts arcfour-hmac-md5 des3-hmac-sha1 des-cbc-crc des-cbc-md5
  15. v4_instance_resolve = false
  16. v4_name_convert = {
  17. host = {
  18. rcmd = host
  19. ftp = ftp
  20. }
  21. plain = {
  22. something = something-else
  23. }
  24. }
  25. fcc-mit-ticketflags = true
  26. [realms]
  27. SCI.COM = {
  28. kdc = dc01.sci.com
  29. admin_server = dc01.sci.com
  30. default_domain = SCI.COM
  31. }
  32. [domain_realm]
  33. .sci.com = SCI.COM
  34. sci.com = SCI.COM
  35. [login]
  36. krb4_convert = true
  37. krb4_get_tickets = false
  38.  


- แก้ไฟล์ smb.conf
  1. nano /etc/samba/smb.conf

แทนที่ทั้งหมด
  1. [global]
  2. security = ads
  3. realm = SCI.COM
  4. password server = dc01.sci.com
  5. workgroup = SCI
  6. idmap uid = 10000-20000
  7. idmap gid = 10000-20000
  8. winbind enum users = yes
  9. winbind enum groups = yes
  10. template homedir = /home/%U
  11. template shell = /bin/bash
  12. client use spnego = yes
  13. client ntlmv2 auth = yes
  14. encrypt passwords = yes
  15. winbind use default domain = yes
  16. restrict anonymous = 2
  17. map acl inherit = yes
  18. nt acl support = yes
  19. disable spoolss = yes
  20. wins server = 192.168.0.253
  21.  


- join domain ด้วยคำสั่ง
  1. net rpc join ads SCI.COM -S dc01.sci.com -U Administrator

หรือ
  1. net ads join SCI.COM -S dc01.sci.com -U Administrator


- restart service
  1. /etc/init.d/smbd restart 
  1. /etc/init.d/winbind restart


- test kerberos
  1. kinit Administrator@SCI.COM  #domain ใช้ตัวพิมพ์ใหญ่
  2.     klist

ควรจะได้ผลลัพธ์ ประมาณนี้
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: Administrator@SCI.COM

Valid starting Expires Service principal
02/24/11 13:31:44 02/24/11 20:11:44 krbtgt/SCI.COM@SCI.COM


- get group get user
  1. wbinfo -u
#แสดงรายการ user ใน domain
  1. wbinfo -g
#แสดงรายการ group ใน domain

- get password get group AD
  1. getent passwd
#จะเห็นรายชื่อบน AD
  1. getent group
#จะเห็น group บน AD

- แก้ squid.conf
  1. nano /etc/squid/squid.conf

copy config บางส่วนที่ใช้ block มา จากเครื่องเดิม

แก้ squid บางส่วน
  1. acl localnet src 192.168.0.0/24 192.168.100.0/24
  2. http_access allow localnet
  3. http_port 8080
  4.  


ส่วนของ Authentication แก้เป็นดังนี้ ส่วนที่ต่างจาก Version เก่า คือสีแดง
  1. auth_param basic program /usr/lib/squid3/basic_ldap_auth -R -b "dc=sci,dc=com" -D "cn=ldap-user,cn=Users,dc=sci,dc=com" -w "password" -f "sAMAccountName=%s" -h 192.168.0.254
  2.     auth_param basic children 5
  3.     auth_param basic realm Squid proxy-caching web server
  4.     auth_param basic credentialsttl 5 minutes


  1. external_acl_type InetGroup %LOGIN /usr/lib/squid3/ext_wbinfo_group_acl
  2. acl InetAccess external InetGroup InetAllow
  3. http_access allow InetAccess

  1. acl webblocked url_regex '/etc/squid/webblocked.txt'
  2. acl day_am time 08:00-12:00
  3. acl day_pm time 13:00-17:40
  4. http_access deny webblocked day_am
  5. http_access deny webblocked day_pm


- copy พวกไฟล์ webblocked.txt จากเครื่องเดิมมา

- restart service
  1. /etc/init.d/squid restart


- test Authen ว่าผ่านหรือไม่
  1. echo "suwit_j InetAllow" | /usr/lib/squid/ext_wbinfo_group_acl -d

ต้องได้ผลลัพท์แบบนี้
Debugging mode ON.
Got suwit_j InetAllow from squid
User: -suwit_j-
Group: -InetAllow-
SID: -S-1-5-21-2702268678-3437982827-1986072043-3107-
GID: -10019-
Sending OK to squid
OK


- Test Set proxy on browser.

นำ Cache จากเครื่องเดิมมาใช้งานต่อ
- snap เครื่องเดิม เพื่อเอา disk cache ไปใส่เครื่องใหม่
- download file vmdk
จะได้ไฟล์ 2 ไฟล์ .vmdk และ flat.vmdk
- upload ขึ้น folder ที่ต้องการ
- add disk ใส่ VMware
- ดู disk dev อะไร
  1. fdisk -l

- สร้าง folder สำหรับ mount disk cache
  1. mkdir /cache

- mount disk ใส่ /cache
  1. mount /dev/sdb1 /cache

- mount auto
  1. nano /etc/fstab
  1. /dev/sdb1 /cache reiserfs notail,noatime 1 2


- แก้ squid.conf
  1. nano /etc/squid/squid.conf

เพิ่ม
  1. cache_dir ufs /cache 10240 32 512
  2. cache_mem 64 MB
  3.  
  4. #cache_effective_user proxy
  5. #cache_effective_group proxy
  6.  
  7. maximum_object_size 64 MB
  8. maximum_object_size_in_memory 64 KB
  9.  
  10. memory_replacement_policy heap LFUDA
  11. cache_replacement_policy heap LFUDA


-restar service
  1. /etc/init.d/squid restart


- gen reports แล้วดู lightsquid ที่มี hit ว่ามีการใช้งานหรือไม่ถ้ามี แสดงว่าใช้งานจาก cache
  1. /usr/local/lightsquid/lightparser.pl

No comments:

Post a Comment