Squid+Privoxy+Tor
squid
nano /etc/squid/squid.conf
######################################################## # ОСНОВНЫЕ НАСТРОЙКИ SQUID ######################################################## # Отключение проверки имён хостов check_hostnames off # Определение локальных сетей (RFC 1918 и др.) acl localnet src 0.0.0.1-0.255.255.255 # "this" network (LAN) acl localnet src 10.0.0.0/8 # RFC 1918 private acl localnet src 100.64.0.0/10 # RFC 6598 CGN acl localnet src 169.254.0.0/16 # RFC 3927 link-local acl localnet src 172.16.0.0/12 # RFC 1918 private acl localnet src 192.168.0.0/16 # RFC 1918 private acl localnet src fc00::/7 # RFC 4193 private acl localnet src fe80::/10 # RFC 4291 link-local # ACL для блокируемых/специальных ресурсов acl russia_block_list url_regex "/etc/squid/eais.list" acl onion_list url_regex -i .*://.*\.onion\/.* # ACL для разделения HTTP/HTTPS .i2p acl i2p_http url_regex -i ^http://.*\.i2p(/.*)?$ acl i2p_https url_regex -i ^https://.*\.i2p(/.*)?$ ######################################################## # НАСТРОЙКА PEER-СЕРВЕРОВ (UPSTREAM PROXIES) ######################################################## # HTTP .i2p → порт 4444 cache_peer 192.168.1.131 parent 4444 4444 no-digest \ protocol=http \ name=i2p_http_peer \ connect-timeout=15 \ request-timeout=60 \ dead-peer-timeout=30 \ round-robin # HTTPS .i2p → порт 4445 cache_peer 192.168.1.131 parent 4445 4445 no-digest \ protocol=https \ name=i2p_https_peer \ connect-timeout=15 \ request-timeout=60 \ dead-peer-timeout=30 \ round-robin # privoxy peer (порт 8118) cache_peer 192.168.1.131 parent 8118 8118 no-digest \ protocol=http \ name=privoxy_peer \ connect-timeout=15 \ request-timeout=60 \ dead-peer-timeout=30 \ round-robin ######################################################## # ПРАВИЛА ДОСТУПА К PEER-СЕРВЕРАМ ######################################################## cache_peer_access i2p_http_peer allow i2p_http cache_peer_access i2p_https_peer allow i2p_https cache_peer_access privoxy_peer allow onion_list cache_peer_access privoxy_peer allow russia_block_list ######################################################## # ПРАВИЛА НАПРАВЛЕНИЯ ЗАПРОСОВ ######################################################## # never_direct: всегда использовать peer для указанных ACL never_direct allow i2p_http never_direct allow i2p_https never_direct allow onion_list never_direct allow russia_block_list never_direct deny localnet # always_direct: никогда не использовать peer для указанных ACL always_direct deny i2p_http always_direct deny i2p_https always_direct deny onion_list always_direct deny russia_block_list always_direct allow localnet ######################################################## # HTTP-ДОСТУП И БЕЗОПАСНОСТЬ ######################################################## # Разрешить доступ из локальных сетей http_access allow localnet # Файл hosts для разрешения имён hosts_file /etc/squid/hosts # Порты для безопасных соединений 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 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 # Запретить CONNECT к небезопасным SSL-портам http_access deny CONNECT !SSL_ports # Доступ для менеджера (только локально) http_access allow localhost manager http_access deny manager # Включить дополнительные конфиги include /etc/squid/conf.d/* # Разрешить локальный доступ http_access allow localhost # Запретить всё остальное http_access deny all ######################################################## # ПОРТ И ДИРЕКТОРИИ ######################################################## # Основной HTTP-порт прокси http_port 3128 # Директория для coredump 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 ######################################################## # ДОПОЛНИТЕЛЬНЫЕ НАСТРОЙКИ (ОПЦИОНАЛЬНО) ######################################################## # Уровень отладки (раскомментировать при необходимости) # debug_options ALL,1 33,2 # Логирование доступа (стандартный формат) access_log /var/log/squid/access.log # Логирование кэша cache_log /var/log/squid/cache.log # Размер кэша (пример: 10 ГБ) # cache_dir ufs /var/spool/squid 10240 16 256 # Максимальный размер объекта в кэше (например, 100 МБ) # maximum_object_size 102400 KB # DNS-серверы (если требуется) # dns_nameservers 8.8.8.8 1.1.1.1 # dns_timeout 15 seconds
Privoxy
nano /etc/privoxy/config
#
# https://www.privoxy.org/user-manual/config.html
#
listen-address 192.168.1.131:8118
#ExitNodes {za}
#StrictNodes 1
user-manual /usr/share/doc/privoxy/user-manual
confdir /etc/privoxy
logdir /var/log/privoxy
actionsfile match-all.action # Actions that are applied to all sites and maybe overruled later on.
actionsfile default.action # Main actions file
actionsfile user.action # User customizations
filterfile default.filter
filterfile user.filter # User customizations
logfile logfile
debug 1 # Log the destination for each request. See also debug 1024.
debug 2 # show each connection status
debug 4 # show tagging-related messages
debug 8 # show header parsing
#debug 16 # log all data written to the network
debug 32 # debug force feature
debug 64 # debug regular expression filters
debug 128 # debug redirects
#debug 256 # debug GIF de-animation
debug 512 # Common Log Format
debug 1024 # Log the destination for requests Privoxy didn't let through, and the reason why.
debug 2048 # CGI user interface
debug 4096 # Startup banner and warnings.
debug 8192 # Non-fatal errors
#debug 32768 # log all data read from the network
#debug 65536 # Log the applying actions
toggle 1
enable-remote-toggle 0
enable-remote-http-toggle 0
enable-edit-actions 0
enforce-blocks 0
buffer-limit 4096
enable-proxy-authentication-forwarding 0
forward-socks5 / localhost:9050 . # перенаправляем траффик на tor socks proxy (на тор)
forward-socks4 / localhost:9050 . # перенаправляем траффик на tor socks proxy (на тор)
forward-socks4a / localhost:9050 . # перенаправляем траффик на tor socks proxy (на тор)
forward-socks4a .onion localhost:9050 . # Если домен .onion - то через tor
forward .i2p localhost:4444 . # если домен .i2p - идем на него через i2p роутер
forward 192.168.*.*/ . # локалку не трогаем forward 10.*.*.*/ . #равно как и VPN
forward 127.*.*.*/ .
forwarded-connect-retries 0
accept-intercepted-requests 1 # это позволит делать прозрачное проксирование через iptables
allow-cgi-request-crunching 0
split-large-forms 0
keep-alive-timeout 5
tolerate-pipelining 1
socket-timeout 300
Tor
nano /etc/tor/torrc
# # https://www.torproject.org/docs/faq#torrc # https://manpages.debian.org/bullseye/tor/torrc.5.en.html # curl -x socks5h://localhost:9050 -s https://check.torproject.org/api/ip # SocksPort localhost:9050 ControlPort localhost:9051 # Log notice file /var/log/tor/notices.log Log debug file /var/log/tor/debug.log # DataDirectory /var/lib/tor CookieAuthentication 0 User debian-tor Group debian-tor RunAsDaemon 1 # Эти настройки немного ускоряют работу - важно для слабых устройств CircuitBuildTimeout 30 KeepAlivePeriod 60 NewCircuitPeriod 15 NumEntryGuards 8 # Это позволяет ограничить количество используемых сокетов - важно при работе на опять-таки "вялых" устройствах и на арендованных серверах ConstrainedSockets 1 # Мининизировать запись на диск - это важно для устройств, система которых находится на флешке AvoidDiskWrites 1 # bridges ClientTransportPlugin obfs4 exec /usr/bin/obfs4proxy Bridge obfs4 [2400:8902::f03c:92ff:feab:489e]:7987 9F539B9E42AB86BFDFD8B3760138A39E67395589 cert=FjKytP43NmYEklG4ScIBhYIXfSe05oVIEKVu4h87gZU+x/l7B5E/pQSYo60Mc/qduhgSXQ iat-mode=0 Bridge webtunnel [2001:db8:3d87:58ab:4ec3:21ba:913f:99d8]:443 E4B91C347D685E929C1B7CE84CC27EB073127EA6 url=https://borntec.autos/poh8aiteaqu6oophaiXo ver=0.0.1 Bridge webtunnel [2001:db8:3d87:58ab:4ec3:21ba:913f:99d8]:443 E4B91C347D685E929C1B7CE84CC27EB073127EA6 url=https://borntec.autos/poh8aiteaqu6oophaiXo ver=0.0.1 Bridge obfs4 185.177.207.137:8443 D6B9EC832A0D9E6A181A62D4D72CC3A9FEDF60CB cert=4Q8yZaa1lzkPmxsbtanABUYaapxko+AoVtsBNoWGC4+YLBCgavxoM3x4Kn+SX3rLVNubDQ iat-mode=0 Bridge obfs4 207.172.185.193:22223 F34AC0CDBC06918E54292A474578C99834A58893 cert=MjqosoyVylLQuLo4LH+eQ5hS7Z44s2CaMfQbIjJtn4bGRnvLv8ldSvSED5JpvWSxm09XXg iat-mode=0 UseBridges 1
Bridges
$ apt install obfs4proxy
RKN
#!/bin/sh curl -fsSL https://raw.githubusercontent.com/zapret-info/z-i/master/dump.csv \ | sed 1d \ | cut -d ';' -f 3 \ | tr "\|" "\n" \ | sed 's/^[ \t]*//;s/[ \t]*$//' \ | uniq > /etc/squid/zapret-urls.txt #“sed 1d” — отрезаем первую строку #“cut -d ';' -f 3“ — вырезаем все, кроме третьей колонки. #tr "\|" "\n" — заменяем символ | на символ переноса строки #sed 's/^[ \t]*//;s/[ \t]*$//' — обрезаем пробелы и табуляцию #uniq — удаляем дублирующиеся строки.