Различия
Показаны различия между двумя версиями страницы.
| Предыдущая версия справа и слева Предыдущая версия Следующая версия | Предыдущая версия | ||
| proxy:network:proxy [2023/12/13 22:19] – [Privoxy] mirocow | proxy:network:proxy [2025/11/05 11:58] (текущий) – [squid] mirocow | ||
|---|---|---|---|
| Строка 1: | Строка 1: | ||
| - | {{tag> | + | {{tag> |
| ====== Squid+Privoxy+Tor ====== | ====== Squid+Privoxy+Tor ====== | ||
| Строка 8: | Строка 8: | ||
| nano / | nano / | ||
| - | < | + | < |
| - | acl manager proto cache_object | + | ######################################################## |
| - | acl localhost | + | # ОСНОВНЫЕ НАСТРОЙКИ SQUID |
| - | acl to_localhost dst 127.0.0.0/ | + | ######################################################## |
| - | acl ftp proto FTP | + | |
| - | acl localnet src 10.0.0.0/8 # RFC1918 possible internal network | + | # Отключение проверки имён хостов |
| - | acl localnet src 172.16.0.0/ | + | check_hostnames off |
| - | acl localnet src 192.168.0.0/ | + | |
| - | acl localnet src fc00::/ | + | # Определение локальных сетей (RFC 1918 и др.) |
| - | acl localnet src fe80::/ | + | acl localnet |
| + | acl localnet src 10.0.0.0/ | ||
| + | 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/ | ||
| + | acl localnet src 192.168.0.0/ | ||
| + | acl localnet src fc00::/ | ||
| + | acl localnet src fe80::/ | ||
| + | |||
| + | # ACL для блокируемых/ | ||
| + | acl russia_block_list url_regex "/ | ||
| + | acl onion_list url_regex -i .*:// | ||
| + | |||
| + | # ACL для разделения HTTP/HTTPS .i2p | ||
| + | acl i2p_http url_regex -i ^http:// | ||
| + | acl i2p_https url_regex -i ^https:// | ||
| + | |||
| + | ######################################################## | ||
| + | # НАСТРОЙКА 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: | ||
| + | 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: | ||
| + | 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 / | ||
| + | |||
| + | # Порты для безопасных соединений | ||
| acl SSL_ports port 443 | acl SSL_ports port 443 | ||
| - | acl Safe_ports port 80 # http | + | acl Safe_ports port 80 # http |
| - | acl Safe_ports port 21 # ftp | + | acl Safe_ports port 21 # ftp |
| - | acl Safe_ports port 443 | + | acl Safe_ports port 443 |
| - | acl Safe_ports port 70 # gopher | + | acl Safe_ports port 70 # gopher |
| - | acl Safe_ports port 210 | + | acl Safe_ports port 210 |
| - | acl Safe_ports port 1025-65535 | + | acl Safe_ports port 1025-65535 |
| - | acl Safe_ports port 280 | + | acl Safe_ports port 280 |
| - | acl Safe_ports port 488 | + | acl Safe_ports port 488 |
| - | acl Safe_ports port 591 | + | acl Safe_ports port 591 |
| - | acl Safe_ports port 777 | + | acl Safe_ports port 777 |
| - | acl Safe_ports port 3128 | + | |
| acl CONNECT method CONNECT | acl CONNECT method CONNECT | ||
| - | http_access allow manager localhost | + | # Запретить доступ к небезопасным портам |
| - | http_access deny manager | + | |
| http_access deny !Safe_ports | http_access deny !Safe_ports | ||
| + | # Запретить CONNECT к небезопасным SSL-портам | ||
| http_access deny CONNECT !SSL_ports | http_access deny CONNECT !SSL_ports | ||
| + | # Доступ для менеджера (только локально) | ||
| + | http_access allow localhost manager | ||
| + | http_access deny manager | ||
| + | |||
| + | # Включить дополнительные конфиги | ||
| + | include / | ||
| + | |||
| + | # Разрешить локальный доступ | ||
| http_access allow localhost | http_access allow localhost | ||
| - | http_access allow all | ||
| - | http_port 3128 | + | # Запретить всё остальное |
| + | http_access deny all | ||
| - | hierarchy_stoplist cgi-bin ? | + | ######################################################## |
| + | # ПОРТ И ДИРЕКТОРИИ | ||
| + | ######################################################## | ||
| - | cache_peer 127.0.0.1 parent 8118 7 no-query no-digest | + | # Основной HTTP-порт прокси |
| + | http_port 3128 | ||
| + | # Директория для coredump | ||
| coredump_dir / | coredump_dir / | ||
| + | |||
| + | ######################################################## | ||
| + | # НАСТРОЙКИ КЭШИРОВАНИЯ | ||
| + | ######################################################## | ||
| refresh_pattern ^ftp: | refresh_pattern ^ftp: | ||
| - | refresh_pattern ^gopher: | + | refresh_pattern ^gopher: |
| - | refresh_pattern -i (/ | + | refresh_pattern -i (/ |
| refresh_pattern . | refresh_pattern . | ||
| + | ######################################################## | ||
| + | # ДОПОЛНИТЕЛЬНЫЕ НАСТРОЙКИ (ОПЦИОНАЛЬНО) | ||
| + | ######################################################## | ||
| - | httpd_suppress_version_string on | + | # Уровень отладки (раскомментировать при необходимости) |
| - | forwarded_for off | + | # debug_options ALL,1 33,2 |
| - | always_direct allow ftp | + | |
| - | never_direct allow all | + | |
| - | </ | + | |
| - | < | + | # Логирование доступа (стандартный формат) |
| - | acl all src all | + | access_log |
| - | acl manager proto cache_object | + | |
| - | acl localhost src 127.0.0.1/32 | + | # Логирование кэша |
| - | acl home_network src 192.168.2.0/24 | + | cache_log |
| - | acl to_localhost dst 127.0.0.0/8 | + | |
| - | acl SSL_ports port 443 | + | # Размер кэша (пример: 10 ГБ) |
| - | acl Safe_ports port 80 # http | + | # cache_dir ufs /var/spool/ |
| - | acl Safe_ports port 21 # ftp | + | |
| - | acl Safe_ports port 443 # https | + | # Максимальный размер объекта в кэше (например, 100 МБ) |
| - | acl Safe_ports port 70 # gopher | + | # maximum_object_size 102400 KB |
| - | acl Safe_ports port 210 # wais | + | |
| - | acl Safe_ports port 1025-65535 # unregistered ports | + | # DNS-серверы (если требуется) |
| - | acl Safe_ports port 280 # http-mgmt | + | # dns_nameservers 8.8.8.8 1.1.1.1 |
| - | acl Safe_ports port 488 # gss-http | + | # dns_timeout 15 seconds |
| - | acl Safe_ports port 591 # filemaker | + | |
| - | acl Safe_ports port 777 # multiling http | + | |
| - | acl Safe_ports port 901 # SWAT | + | |
| - | acl purge method PURGE | + | |
| - | acl CONNECT method CONNECT | + | |
| - | http_access allow home_network | + | |
| - | 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 | + | |
| - | acl malware_domains url_regex '/etc/squid/Malware-domains.txt' | + | |
| - | http_access deny malware_domains | + | |
| - | http_access allow localhost | + | |
| - | http_access deny all | + | |
| - | icp_access deny all | + | |
| - | http_port 3400 | + | |
| - | icp_port 0 | + | |
| - | hierarchy_stoplist cgi-bin ? | + | |
| - | refresh_pattern ^ftp: 1440 20% 10080 | + | |
| - | refresh_pattern ^gopher: 1440 0% 1440 | + | |
| - | refresh_pattern -i (/ | + | |
| - | refresh_pattern . 0 20% 4320 | + | |
| - | cache_peer localhost parent 8118 0 round-robin no-query | + | |
| - | cache_peer localhost2 parent 8129 0 round-robin no-query | + | |
| - | cache_peer localhost3 parent 8230 0 round-robin no-query | + | |
| - | cache_peer localhost4 parent 8321 0 round-robin no-query | + | |
| - | cache_peer localhost5 parent 8421 0 round-robin no-query | + | |
| - | cache_peer localhost6 parent 8522 0 round-robin no-query | + | |
| - | cache_peer localhost7 parent 8623 0 round-robin no-query | + | |
| - | cache_peer localhost8 parent 8724 0 round-robin no-query | + | |
| - | never_direct allow all | + | |
| - | always_direct deny all | + | |
| - | acl apache rep_header Server ^Apache | + | |
| - | broken_vary_encoding allow apache | + | |
| - | forwarded_for off | + | |
| - | coredump_dir / | + | |
| - | cache_dir ufs /home/squid-cache 20000 16 256 # cache-size in MB, Directory-Structure 1, Directory-Structure below 1 | + | |
| - | pid_filename / | + | |
| - | access_log / | + | |
| - | cache_store_log / | + | |
| - | cache_log / | + | |
| </ | </ | ||
| ====== Privoxy ====== | ====== Privoxy ====== | ||
| Строка 145: | Строка 201: | ||
| debug 4 # show tagging-related messages | debug 4 # show tagging-related messages | ||
| debug 8 # show header parsing | debug 8 # show header parsing | ||
| - | debug 16 # log all data written to the network | + | #debug 16 # log all data written to the network |
| debug 32 # debug force feature | debug 32 # debug force feature | ||
| debug 64 # debug regular expression filters | debug 64 # debug regular expression filters | ||
| debug 128 # debug redirects | debug 128 # debug redirects | ||
| - | debug 256 # debug GIF de-animation | + | #debug 256 # debug GIF de-animation |
| debug 512 # Common Log Format | debug 512 # Common Log Format | ||
| debug 1024 # Log the destination for requests Privoxy didn't let through, and the reason why. | debug 1024 # Log the destination for requests Privoxy didn't let through, and the reason why. | ||
| Строка 155: | Строка 211: | ||
| debug 4096 # Startup banner and warnings. | debug 4096 # Startup banner and warnings. | ||
| debug 8192 # Non-fatal errors | debug 8192 # Non-fatal errors | ||
| - | debug 32768 # log all data read from the network | + | #debug 32768 # log all data read from the network |
| - | debug 65536 # Log the applying actions | + | #debug 65536 # Log the applying actions |
| toggle | toggle | ||
| enable-remote-toggle | enable-remote-toggle | ||
| Строка 164: | Строка 220: | ||
| buffer-limit 4096 | buffer-limit 4096 | ||
| enable-proxy-authentication-forwarding 0 | enable-proxy-authentication-forwarding 0 | ||
| - | forward-socks5 / 192.168.1.131:9050 . # перенаправляем траффик на tor socks proxy (на тор) | + | forward-socks5 / localhost:9050 . # перенаправляем траффик на tor socks proxy (на тор) |
| - | forward-socks4 / 192.168.1.131:9050 . # перенаправляем траффик на tor socks proxy (на тор) | + | forward-socks4 / localhost:9050 . # перенаправляем траффик на tor socks proxy (на тор) |
| - | forward-socks4a / 192.168.1.131:9050 . # перенаправляем траффик на tor socks proxy (на тор) | + | forward-socks4a / localhost:9050 . # перенаправляем траффик на tor socks proxy (на тор) |
| - | forward-socks4a .onion | + | forward-socks4a .onion |
| - | #forward .i2p 192.168.1.131:4444 . # если домен .i2p - идем на него через i2p роутер | + | forward .i2p localhost:4444 . # если домен .i2p - идем на него через i2p роутер |
| forward 192.168.*.*/ | forward 192.168.*.*/ | ||
| forward 127.*.*.*/ | forward 127.*.*.*/ | ||
| Строка 179: | Строка 235: | ||
| socket-timeout 300 | socket-timeout 300 | ||
| </ | </ | ||
| + | ====== Tor ====== | ||
| + | [[network: | ||
| + | |||
| + | nano / | ||
| < | < | ||
| - | forward-socks4a | + | # |
| - | confdir | + | # https://www.torproject.org/ |
| - | logdir | + | # https:// |
| - | actionsfile default.action | + | # curl -x socks5h:// |
| - | actionsfile user.action | + | # |
| - | filterfile default.filter | + | SocksPort localhost: |
| + | ControlPort localhost: | ||
| + | # | ||
| + | Log notice file /var/log/tor/notices.log | ||
| + | Log debug file / | ||
| + | # | ||
| + | DataDirectory / | ||
| + | CookieAuthentication 0 | ||
| + | User debian-tor | ||
| + | Group debian-tor | ||
| + | RunAsDaemon 1 | ||
| + | # Эти настройки немного ускоряют работу - важно для слабых устройств | ||
| + | CircuitBuildTimeout 30 | ||
| + | KeepAlivePeriod 60 | ||
| + | NewCircuitPeriod 15 | ||
| + | NumEntryGuards 8 | ||
| + | # Это позволяет ограничить количество используемых сокетов - важно при работе на опять-таки " | ||
| + | ConstrainedSockets 1 | ||
| + | # Мининизировать запись на диск - это важно для устройств, | ||
| + | AvoidDiskWrites 1 | ||
| - | logfile logfile | + | # bridges |
| + | ClientTransportPlugin obfs4 exec / | ||
| + | Bridge obfs4 [2400: | ||
| + | Bridge webtunnel [2001: | ||
| + | Bridge webtunnel [2001: | ||
| + | Bridge obfs4 185.177.207.137: | ||
| + | Bridge obfs4 207.172.185.193: | ||
| + | UseBridges 1 | ||
| + | </ | ||
| - | debug 4096 # Startup banner and warnings | + | ====== Bridges ====== |
| - | debug 8192 # Errors - *we highly recommended enabling this* | + | |
| - | user-manual | + | * <code bash>$ apt install obfs4proxy< |
| - | listen-address | + | * https://bridges.torproject.org/options/ |
| - | toggle | + | |
| - | enable-remote-toggle 0 | + | |
| - | enable-edit-actions 0 | + | |
| - | enable-remote-http-toggle 0 | + | |
| - | buffer-limit 4096 | + | |
| - | </code> | + | |
| - | < | + | ===== RKN ===== |
| - | actionsfile standard.action # Internal purpose, recommended | + | |
| - | actionsfile default.action # Main actions file | + | |
| - | actionsfile user.action # User customizations | + | |
| - | actionsfile neilvandyke.action # http:// | + | |
| - | filterfile default.filter | + | |
| - | logfile logfile | + | |
| - | toggle 1 | + | |
| - | enable-remote-toggle 0 | + | |
| - | enable-remote-http-toggle 0 | + | |
| - | enable-edit-actions 1 | + | |
| - | enforce-blocks 0 | + | |
| - | buffer-limit 4096 | + | |
| - | forwarded-connect-retries 0 | + | |
| - | accept-intercepted-requests 0 | + | |
| - | allow-cgi-request-crunching 0 | + | |
| - | split-large-forms 0 | + | |
| - | </ | + | |
| - | ====== Tor ====== | + | |
| - | [[network:tor]] | + | <code bash> |
| + | #!/bin/sh | ||
| + | curl -fsSL https:// | ||
| + | | sed 1d \ | ||
| + | | cut -d ';' | ||
| + | | tr " | ||
| + | | sed 's/^[ \t]*//;s/[ \t]*$//' \ | ||
| + | | uniq > / | ||
| - | nano / | + | #“sed 1d” — отрезаем первую строку |
| - | < | + | #“cut -d ';' |
| - | SocksPort 9050 # what port to open for local application connections | + | #tr " |
| - | SocksBindAddress 127.0.0.1 | + | #sed 's/^[ \t]*//;s/[ \t]*$//' |
| - | AllowUnverifiedNodes middle,rendezvous | + | #uniq — удаляем дублирующиеся строки. |
| - | Log notice syslog | + | |
| - | </code> | + | |
| - | + | ||
| - | < | + | |
| - | SocksBindAddress 127.0.0.1 # accept connections only from localhost | + | |
| - | AllowUnverifiedNodes middle, | + | |
| - | Log notice syslog | + | |
| - | RunAsDaemon 1 | + | |
| - | User tor | + | |
| - | Group tor | + | |
| - | CircuitBuildTimeout 30 | + | |
| - | NumEntryGuards 6 | + | |
| - | KeepalivePeriod 60 | + | |
| - | NewCircuitPeriod 15 | + | |
| </ | </ | ||