LinuxForum.Fans
Тема

Squid + белый лист

Автор: XliN 4 сообщений 2938 просмотров
#235656

Есть настроенный squid. Авторизация идет через LDAP. Нужно сделать белый список для пользователей в группе insured.
Что бы они открывали только один сайт и все.
Сейчас пользователи в группе IA имеют полный доступ в инет. Была хорошая хавтушка на примере gentoo, но что то не могу найти. Подскажите кто знает.
Вот конфиг сквида

Показать

http_port 3128
auth_param basic program /usr/lib/squid/squid_ldap_auth \
-b "dc=smb,dc=mgkb1,dc=local" \
-D sel_ldap@smb.mgkb1.local \
-w XXXXXXXXXX \
-f "(&(objectClass=person)(sAMAccountName=%s))" \
-u sAMAccountName \
-h 192.168.2.82 -p 389

auth_param basic children 50
auth_param basic realm Internet Access MGKB1
auth_param basic credentialsttl 1 minutes
auth_param basic casesensitive off

external_acl_type ldap_users %LOGIN /usr/lib/squid/squid_ldap_group -f \
"(&(objectclass=person)(sAMAccountName=%v) \
(memberOf=CN=ia,CN=Builtin,DC=smb,DC=mgkb1,DC=local))" -R -b \
"OU=UsersDom,DC=smb,DC=mgkb1,DC=local" \
-D "reg3@smb.mgkb1.local" -w "XXXXXXXXXXXX" \
-h 192.168.2.82 -v 3 -p 389

hierarchy_stoplist cgi-bin ?

coredump_dir /var/spool/squid

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern . 0 20% 4320

access_log /var/log/squid/access.log squid

cache_mem 256 MB
cache_effective_user squid
cache_effective_group squid
cache_dir ufs /var/spool/squid/ 1024 16 256
cache_swap_low 97
cache_swap_high 100

acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl inetusers external ldap_users ia
acl media urlpath_regex -i \.mp3$ \.asf$ \.wma$

dns_nameservers 192.168.1.77 192.168.3.223

acl SSL_ports port 443
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 # https
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
acl Safe_ports port 1025-65535 # unregistered ports
acl Safe_ports port 280 # http-mgmt
acl Safe_ports port 488 # gss-http
acl Safe_ports port 591 # filemaker
acl Safe_ports port 777 # multiling http
acl CONNECT method CONNECT


delay_pools 2
# ограничим mp3 до 30 Кб/с
delay_class 1 1
delay_parameters 1 30000/30000
delay_access 1 allow media
delay_access 1 deny all

# ограничим ldap users до 150 Кб/с
delay_class 2 1
delay_parameters 2 150000/150000
delay_access 2 allow inetusers
delay_access 2 deny all

http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports

http_access deny CONNECT !SSL_ports

http_access allow inetusers
http_access allow localhost
http_access deny all

http_reply_access allow all
icp_access allow all

coredump_dir /var/spool/squid


log_fqdn on
# Настроим ротацию логов
logfile_rotate 1
# Отключить удаление параметров передаваемых в URL запросе
strip_query_terms off
logformat squid %ts %6tr %>A %Ss/%03Hs %<st %rm %ru %un %Sh/%<A %mt
#235705
text
Restricting Access to specific Web sites

Squid is also capable of reading files containing lists of web sites and/or domains for use in ACLs. In this example we create to lists in files named /usr/local/etc/allowed-sites.squid and /usr/local/etc/restricted-sites.squid. # File: /usr/local/etc/allowed-sites.squid www.openfree.org linuxhomenetworking.com

# File: /usr/local/etc/restricted-sites.squid www.porn.com illegal.com These can then be used to always block the restricted sites and permit the allowed sites during working hours. This can be illustrated by expanding our previous example slightly. # # Add this to the bottom of the ACL section of squid.conf # acl home_network src 192.168.1.0/24 acl business_hours time M T W H F 9:00-17:00 acl GoodSites dstdomain "/usr/local/etc/allowed-sites.squid" acl BadSites dstdomain "/usr/local/etc/restricted-sites.squid"

# # Add this at the top of the http_access section of squid.conf # http_access deny BadSites http_access allow home_network business_hours GoodSite

http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch32_:_Controlling_Web_Access_with_Squid#Access_Control_Lists

#235714

Сделал уже. Пришлось чуть переписать филтр для проверки пользователей в группе.

#236106

А вот собственно решение
Исправляем проверку пользователя в группе. Раньше он искал только в конкретной, теперь ищет везде

external_acl_type ldap_users %LOGIN /usr/lib/squid/squid_ldap_group -R -b "OU=UsersDom,DC=smb,DC=mgkb1,DC=local" -f "(&(sAMAccountName=%v)(memberOf=CN=%a,CN=Builtin,DC=smb,DC=mgkb1,DC=local))" -D sel_ldap@smb.mgkb1.local -w "XXXXXX" 192.168.2.82 -v 3 -p 389

Ну и дописываем правила и разрешения

acl insured_user external ldap_users insured
acl small_allow url_regex -i "/etc/squid/Privilegy_list"
http_access allow insured_user small_allow
Войдите или зарегистрируйтесь, чтобы ответить.