Wednesday, July 22, 2009

Быстрая настройка squid

Быстрая настройка Squid. Показан пример ограничений (delay_pools)

Редактируем файл настройки #nano /etc/squid/squid.conf

acl all src all
acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl lgtd src 192.168.1.0/24 #Диапазон вашей сети. lgtd - название списка.
acl purge method PURGE
acl CONNECT method CONNECT

acl SSL_ports port 443 563 # https, snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
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 Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT


http_access allow manager localhost
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost
http_access allow lgtd # Разрешаем доступ компьютерам локальной сети.
http_access deny all # Запрещаем доступ всем остальным

icp_access allow lgtd
icp_access deny all

http_port 192.168.1.254:8080 # адрес и порт компьютера где запущен squid. (можна указовать только порт)

hierarchy_stoplist cgi-bin ?

access_log /var/log/squid/access.log squid # Где будут зранитсья логи

refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Package(.gz)*)$ 0 20% 2880
refresh_pattern . 0 20% 4320

acl shoutcast rep_header X-HTTP09-First-Line ^ICY\s[0-9]

upgrade_http0.9 deny shoutcast

acl apache rep_header Server ^Apache

broken_vary_encoding allow apache

extension_methods REPORT MERGE MKACTIVITY CHECKOUT

acl media urlpath_regex -i \.mp3$ \.asf$ \.wma$ \.flv$ \.avi$ # задаем лист медиа файлов

# Правила ограничений

delay_pools 2 # Всего используем 2 правила

delay_class 1 1
delay_parameters 1 10000/10000 #Ограничили скорость закачки медиа файлов до 10кб
delay_access 1 allowmedia
delay_access 1 deny all

delay_class 2 2
delay_parameters 2 -1/-1 32000/32000 # На всю сеть максимальная скорость, на клиента 32кб
delay_access 2 allow lgtd
delay_access 2 deny all

hosts_file /etc/hosts

coredump_dir /var/spool/squid
Загружаем новый настройки в squid #/etc/init.d/squid reload
Перезапускаем squid #/etc/init.d/squid restart

Поздравляю ваш прокси Squid настроен.

No comments:

Post a Comment