Вариант быстрой и простой настройки SQUID (копипаст и запуск). Хороший вариант для начинающего пользователя, которому пришлось столкнуться с ним.
Устанавливаем SQUID
yum install squid
Редактируем файл настройки /etc/squid/squid.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#обязательно укажем порт
http_port 3128 transparent
#определяем видимое имя прокси-сервера:
visible_hostname имя_сервера
#разрешаем доступ пользователям, например, с диапазона адресов 192.168.0.100-192.168.0.120
#назовем список allowed_hosts
acl allowed_hosts src 192.168.0.100-192.168.0.120/255.255.255.255
#открываем доступ по localhost
acl localhost src 127.0.0.1/255.255.255.255
#определяем остальных пользователей. То есть просто пускаем всех, авторизация отсутствует.
acl all src 0.0.0.0/0.0.0.0
#открываем порты для icq, ssl
acl icq_ports port 443 563 5190
#открываем порты для работы с http, ftp
acl open_ports port 80 8000 8080 443 # http
acl open_ports port 21 # открываем доступ по ftp
#разрешаем доступ для localhost
http_access allow localhost
#разрешаем доступ для "разрешенных"
http_access allow allowed_hosts
#открываем порта для работы icq
http_access allow icq_ports
#открываем порта для http, ftp
http_access allow open_ports
#запрещаем всем остальным доступ к прокси-серверу
http_access deny all
#забиваем данные по логам
access_log /var/log/squid/access.log
cache_effective_user squid
cache_effective_group squid
#забиваем данные для кеш.
cache_mem 512 MB
cache_dir ufs /var/spool/squid 2048 16 256
cache_swap_high 99
cache_swap_low 95
maximum_object_size 12 MB
minimum_object_size 0 KB
#кешируем то, что редко обновляется
refresh_pattern -i \.pdf$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.zip$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.tar$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.gz$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.tgz$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.exe$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.prz$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.ppt$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.inf$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.swf$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.mid$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.wav$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.mp3$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.flw$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.rpm$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern -i \.cab$ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://ad\. 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://ads\. 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://adv\. 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://click\. 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://clck\. 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://count\. 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://counter\. 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://engine\. 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://img\.readme\.ru 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://userpic\.livejournal\.com 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern \.ru/bf-analyze 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern \.ru/bf-si 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern /advs/ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern /banners/ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern /cgi-bin/iframe/ 604800 100% 604800 override-lastmod override-expire ignore-reload ignore-no-cache
refresh_pattern http://odnoklassniki\.ru 604800 100% 604800 override-expire override-lastmod ignore-reload
refresh_pattern http://fbcdn\.net 604800 100% 604800 override-expire override-lastmod ignore-reload
refresh_pattern http://odnoklassniki\.ru 604800 100% 604800 override-expire override-lastmod ignore-reload
refresh_pattern http://www.tns-counter\.ru 604800 100% 604800 override-expire override-lastmod ignore-reload
refresh_pattern -i http://counter\.yadro\.ru 604800 100% 604800 override-expire override-lastmod reload-into-ims ignore-reload
refresh_pattern -i http://24log\.ru 604800 100% 604800 override-expire override-lastmod ignore-reload
cache_replacement_policy heap LFUDA
memory_replacement_policy heap LFUDA
Запускаем прокси
1
/etc/init.d/squid start
Очистить кеш
По сути, действие, которое редко когда вам пригодится. Но мало ли:
GUI ( Графическая оболочка ) для SQUID
Как такового отдельно не нашел, но для этого с успехом можно использовать webmin . Он поможет удобно настроить SQUID, если где-то есть пробелы в знаниях.
Прозрачный прокси ( proxy )
Это нужно для того, чтобы не настраивать все браузеры самому, а перенаправить пользователей на squid без дополнительной настройки. Давайте посмотрим это на примере перенаправления всех веб-запросов на прокси. Для начала убедитесь, что прокси-сервер является шлюзом по-умолчанию.
Далее для iptables задайте такое правило:
1
-A PREROUTING -s 192.168.0.0/255.255.255.0 -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128
Где:
*192.168.0.0/255.255.255.0 - ваша подсеть
*–dport 80 - запрашиваемый порт.
*–to-ports 3128 - порт прокси-сервера.
Теперь все запросы, идущие от пользователей на 80-й порт, будут редиректиться на порт 3128, который обслуживает наш горячо любимый SQUID. Не надо будет бегать и всем настраивать параметры proxy в настройках браузера.