Архив заметок

SQUID в качестве обычного прокси

Просмотров: 2204Комментарии: 0
FreeBSD

Всем привет!

Данная запись не преследует цели описать конфигурацию кэширующего и прозрачного squid сервера с файрволлом или интеграцией с AD. Родилась идея настроить на VPS прокси сервачок для личных нужд с жирным каналом. Для этого я взял за основу систему FreeBSD 12. Начнем:

# uname -srm
FreeBSD 12.0-RELEASE-p8 amd64

Конфиг squid(на эту дату версия 4.8)

http_port ваш_ip:3128
auth_param basic program /usr/local/libexec/squid/basic_ncsa_auth /usr/local/etc/squid/passwd
auth_param basic children 5
auth_param basic realm please sug min den
auth_param basic credentialsttl 2 hours
visible_hostname "proxy"
acl ncsa_users proxy_auth REQUIRED
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
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access deny to_localhost
http_access allow ncsa_users
http_access deny all
access_log /var/log/squid/access.log squid
logfile_rotate 0
via off
forwarded_for off
follow_x_forwarded_for deny all
request_header_access X-Forwarded-For deny all
#logformat squid %tl %6tr %>a %Ss/Hs %<st %rm %ru %un %Sh/%<A %mt
client_db on
dns_defnames on
httpd_suppress_version_string on
retry_on_error on
uri_whitespace strip
strip_query_terms off
cache deny all
#cache_dir null /tmp
ident_lookup_access deny all
#deny_info [URL]http://proxy/blocked.html[/URL] adsites
acl ads dstdom_regex "/usr/local/etc/squid/ad_block.txt"
http_access deny ads

Для создания файла с учетками нужна программка htpasswd, а ставить apache из-за одной проги не комильфо. В портах есть такая штука security/py-htpasswd или можно установить из пакетов, кому как удобнее.

Далее организовать ссылочку:

# ln -s /usr/local/bin/htpasswd.py /usr/local/bin/htpasswd
# rehash

Делаем учетку с паролем:

#htpasswd -cb /usr/local/etc/squid/passwd user password

Почти готово. Теперь надо в файлик ad_block.txt закачать ссылки по рекламе для блокировки. Взял данную фишку отсюда.

Создаем скрипт:

curl -sS -L --compressed "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=nohtml&showintro=0&mimetype=plaintext" > /usr/local/etc/squid/ad_block.txt
## refresh squid
/usr/local/sbin/squid -k reconfigure

Делаем исполняемым:

# chmod +x ad_servers_newlist.sh

И в cron его(я использую рутовый):

# crontab -e
35   5    *   *   */3 /root/ad_servers_newlist.sh >> /dev/null 2>&1
Оставьте комментарий!

grin LOL cheese smile wink smirk rolleyes confused surprised big surprise tongue laugh tongue rolleye tongue wink raspberry blank stare long face ohh grrr gulp oh oh downer red face sick shut eye hmmm mad angry zipper kiss shock cool smile cool smirk cool grin cool hmm cool mad cool cheese vampire snake excaim question

Используйте нормальные имена.

Вы можете войти под своим логином или зарегистрироваться на сайте.

(обязательно)