Squid — программный пакет, реализующий функцию кэширующего прокси-сервера для протоколов HTTP, FTP, Gopher и HTTPS. Разработан сообществом как программа с открытым исходным кодом. Все запросы выполняет как один неблокируемый процесс ввода-вывода.
Проверенная комбинация. Делал на FreeBSD 10.0 (i386).
Обновляем порты. Собираем squid3.
# cd /usr/ports/www/squid# make config
Выбираем пункты, чтобы было так
Options for squid
[ ] SQUID_KERB_AUTH Install Kerberos authentication helpers
[ ] SQUID_LDAP_AUTH Install LDAP authentication helpers
[ ] SQUID_NIS_AUTH Install NIS/YP authentication helpers
[ ] SQUID_SASL_AUTH Install SASL authentication helpers
[ ] SQUID_DELAY_POOLS Enable delay pools
[ ] SQUID_SNMP Enable SNMP support
[ ] SQUID_CARP Enable CARP support
[X] SQUID_SSL Enable SSL support for reverse proxies
[X] SQUID_PINGER Install the icmp helper
[ ] SQUID_DNS_HELPER Use the old ‘dnsserver’ helper
[ ] SQUID_HTCP Enable HTCP support
[ ] SQUID_VIA_DB Enable forward/via database
[ ] SQUID_CACHE_DIGESTS Enable cache digests
[X] SQUID_WCCP Enable Web Cache Coordination Prot. v1
[ ] SQUID_WCCPV2 Enable Web Cache Coordination Prot. v2
[ ] SQUID_STRICT_HTTP Be strictly HTTP compliant
[X] SQUID_IDENT Enable ident (RFC 931) lookups
[ ] SQUID_REFERER_LOG Enable Referer-header logging
[X] SQUID_USERAGENT_LOG Enable User-Agent-header logging
[ ] SQUID_ARP_ACL Enable ACLs based on ethernet address
[ ] SQUID_PF Enable transparent proxying with PF
[X] SQUID_IPFILTER Enable transp. proxying with IPFilter
[ ] SQUID_FOLLOW_XFF Follow X-Forwarded-For headers
[ ] SQUID_AUFS Enable the aufs storage scheme
[ ] SQUID_COSS Enable the COSS storage scheme
[X] SQUID_KQUEUE Use kqueue(2) instead of poll(2)
[ ] SQUID_LARGEFILE Support log and cache files >2GB
[ ] SQUID_STACKTRACES Create backtraces on fatal errors
Жмем ОК и собираем
# make BATCH=yes install clean
Привел конфиг “сквиды” /usr/local/etc/squid/squid.conf до следующего состояния
acl localnet src 192.168.0.0/24
# RFC1918 possible internal network
acl SSL_ports port 443
acl Safe_ports port 80
# http
acl Safe_ports port 21
# ftp
acl Safe_ports port 110
# pop
acl Safe_ports port 25
# smtp
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
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localhost manager
http_access deny manager
http_access allow localnet
http_access allow localhost
http_access deny all
http_port 3128 transparent
http_port 8080
coredump_dir /var/squid/cacherefresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|?) 0 0% 0
refresh_pattern . 0 20% 4320
visible_hostname gw0
Squid готов. Добавим его запуск при старте системы.
# echo ‘squid_enable=»YES»‘ >> /etc/rc.conf
И запускаем
# service squid start
Осталось “завернуть” весь http трафик на “сквиду”. Добавим в конфиг pf следующую строку:
# rdr on $lan_if proto { tcp } from 192.168.0.0/24 to any port 80 -> 127.0.0.1 port 3128
где lan_if – наш интерфейс, который смотрит в локальную сеть.
Перезагружаем pf
# service pf reload
И, если все сделано правильно, наш шлюз прогоняет весь http через squid. Можно убедиться в этом посмотрев на лог доступа:
# tail -f /var/log/squid/access.log
Если в cache.log видим постоянно такое:
IpIntercept.cc(316) PfInterception: PF open failed: (13) Permission denied
Добавить в /etc/devfs.conf
# Allow Squid read acess to /dev/pfown pf root:squidperm pf 0640
и выполнить
/etc/rc.d/devfs restart