10/23/2025

Config squid 5.7

 

Config squid 5.7
คำอธิบาย Authorization ประกอบด้วย 3 ส่วน ใช้ วรรคในการแบ่ง
เช่น
acl web_bypass dstdomain "/etc/squid/web_bypass.txt"

ประกอบด้วย
acl เริ่มต้นด้วยคำสั่ง
web_bypass ตัวแปรที่จะนำไปใช้ในการ allow หรือ denied
"/etc/squid/web_bypass.txt" ค่าที่ต้องการ allow หรือ denied เก็บเป็นไฟล์ หรือใช้ค่า เลยก็ได้
ใช้ค่าเลยเช่น
acl sci_servers dstdomain .sci.com .scivalve.com .alfresco.com


คำสั่ง allow หรือ denied ประกอบด้วย 3 ส่วน ใช้วรรคเป็นตัวแบ่ง เช่น
http_access allow sci_macs

จะขึ้นต้นด้วย http_access เริ่มต้นคำสั่ง
allow จะ allow หรือ denied
sci_macs ตัวแปรที่เก็บค่าไว้ หรือ Fix ค่าไปเลยก็ได้

dstdomain คือ domain ต้องตรงกันกับค่าที่ต้องการ allow หรือ denied
url_regex -i คือ มีคำหรือข้อความนั้นใน ค่าที่ต้องการ allow หรือ denied
rep_mime_type -i mime-type คือชนิดที่ต้องการ เช่น application/x-bittorrent

ส่วนที่ 1 Authorization
  1. forwarded_for on
  2. request_header_access Allow allow all
  3. request_header_access Authorization allow all
  4. request_header_access WWW-Authenticate allow all
  5. request_header_access Proxy-Authorization allow all
  6. request_header_access Proxy-Authenticate allow all
  7. request_header_access Cache-Control allow all
  8. request_header_access Content-Encoding allow all
  9. request_header_access Content-Length allow all
  10. request_header_access Content-Type allow all
  11. request_header_access Date allow all
  12. request_header_access Expires allow all
  13. request_header_access Host allow all
  14. request_header_access If-Modified-Since allow all
  15. request_header_access Last-Modified allow all
  16. request_header_access Location allow all
  17. request_header_access Pragma allow all
  18. request_header_access Accept allow all
  19. request_header_access Accept-Charset allow all
  20. request_header_access Accept-Encoding allow all
  21. request_header_access Accept-Language allow all
  22. request_header_access Content-Language allow all
  23. request_header_access Mime-Version allow all
  24. request_header_access Retry-After allow all
  25. request_header_access Title allow all
  26. request_header_access Connection allow all
  27. request_header_access Proxy-Connection allow all
  28. request_header_access User-Agent allow all
  29. request_header_access Cookie allow all
  30. request_header_access All deny all
  31.  
  32. ################## Start SCI ################################
  33. #acl sci-mac arp 90:21:55:02:6c:e2
  34. acl sci_macs arp "/etc/squid/MAC.lst"
  35. http_access allow sci_macs
  36.  
  37. acl sci_servers dstdomain .sci.com .scivalve.com .alfresco.com
  38. always_direct allow sci_servers
  39. http_access allow sci_servers
  40.  
  41. #Google
  42. acl googles dstdomain .google.com
  43. #always_direct allow googles
  44. http_access allow googles
  45.  
  46. #hotmail
  47. acl HM_SERVER dstdomain .msn.com .hotmail.com .passport.com .live.com .outlook.live.com .outlook.office.net .scivalve.com
  48. http_access allow HM_SERVER
  49.  
  50. acl web_bypass dstdomain "/etc/squid/web_bypass.txt"
  51. http_access allow web_bypass
  52.  
  53. acl GoodSites dstdomain "/etc/squid/goodsites.txt"
  54. #acl GoodSites url_regex -i "/etc/squid/goodsites.txt"
  55. http_access allow GoodSites
  56.  
  57. acl webblocked url_regex -i '/etc/squid/webblocked.txt'
  58. #acl webblocked dstdomain '/etc/squid/webblocked.txt'
  59. http_access deny webblocked
  60. #deny_info denied.html webblocked
  61.  
  62. acl TorrentFiles rep_mime_type -i mime-type application/x-bittorrent
  63. http_reply_access deny TorrentFiles
  64. deny_info TCP_RESET TorrentFiles
  65.  
  66. auth_param basic program /usr/lib/squid/basic_ldap_auth -v 3 -b "cn=Users,dc=sci,dc=com" -D CN=ldap-user,CN=Users,DC=SCI,DC=COM -w PASSWORD -f "(&(sAMAccountName=%s)(objectClass=person)(memberof=CN=InetAllow,OU=SCI,DC=SCI,DC=COM))" -h dc04.sci.com
  67. acl ldap-auth proxy_auth REQUIRED
  68.  
  69. #external_acl_type InetGroup %LOGIN /usr/lib/squid3/ext_wbinfo_group_acl
  70.  
  71. #acl InetAccessFree external InetGroup FreeNet
  72. #http_access allow InetAccessFree
  73.  
  74. acl webblocked_tmp dstdomain '/etc/squid/webblocked_tmp.txt'
  75. acl day_am time 08:00-11:59
  76. acl day_pm time 13:00-17:39
  77. acl day_ot time 18:00-20:59
  78. acl day_after time 21:00-23:59
  79. acl day_before time 00:00-05:59
  80. http_access deny webblocked_tmp day_am
  81. http_access deny webblocked_tmp day_pm
  82. http_access deny webblocked_tmp day_ot
  83. http_access deny webblocked_tmp day_after
  84. http_access deny webblocked_tmp day_before
  85.  
  86. acl domain_blocked dstdomain '/etc/squid/webblocked_https.txt'
  87. http_reply_access deny domain_blocked day_am
  88. http_reply_access deny domain_blocked day_pm
  89. http_reply_access deny domain_blocked day_ot
  90. http_reply_access deny domain_blocked day_after
  91. http_reply_access deny domain_blocked day_before
  92. http_access deny CONNECT domain_blocked day_am
  93. http_access deny CONNECT domain_blocked day_pm
  94. http_access deny CONNECT domain_blocked day_ot
  95. http_access deny CONNECT domain_blocked day_after
  96. http_access deny CONNECT domain_blocked day_before
  97.  
  98. http_access allow ldap-auth
  99. #SCI End 
  100.  

ส่วนที่ 2 localnet และ ports
  1. #Start SCI
  2. acl localnet src 192.168.0.0/24 192.168.100.0/24 192.168.2.0/24
  3. acl SSL_ports port 995          #mail.scivalve.com new
  4. acl SSL_ports port 8443         #scivalve.com new
  5. acl SSL_ports port 443
  6. acl SSL_ports port 993
  7. acl SSL_ports port 2222         # SCI: for hosting
  8. acl SSL_ports port 6301         # gpsiam
  9.  
  10. acl Safe_ports port 80          # http
  11. acl Safe_ports port 110         # SCI: POP3
  12. acl Safe_ports port 587         # SCI: smtp
  13. acl Safe_ports port 25          # SCI: smtp
  14. #End SCI


ส่วนที่ 3 Log Server
  1. #SCI Start Sent Log Squid To Log Server
  2. #Sent To access.log file.
  3. access_log /var/log/squid/access.log squid
  4.  
  5. #Sent To Log Server.
  6. logformat squid %tl %6tr %>a %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
  7. access_log tcp:192.168.2.108:514 squid
  8. #SCI End

No comments:

Post a Comment