Enviado em 27/03/2016 - 18:24h
Pessoal, eu configurei meu squid e ele está rodando normalmente, mas garimpando na net eu verifiquei que é possível emitir certificado openssl com squid para que ele tenha uma eficiência melhor no bloqueio de https. Eu segui os seguintes tutoriais:http://djosino.blogspot.com.br/2012/03/entendendo-e-configurando-squid.html
https://www.vivaolinux.com.br/artigo/Filtragem-de-paginas-SSL-%28443%29-no-Squid-transparente
# General
http_port 3128
https_port 3130 cert=/etc/squid/certificados/cyber.crt key=/etc/squid/certificados/cyber.key
visible_hostname ****
forwarded_for delete
via off
dns_v4_first on
# Log
access_log /var/log/squid/access.log squid
cache_log /var/log/squid/cache.log squid
cache_store_log /var/log/squid/store.log
access_log daemon:/var/log/squid/access.log squid
logformat languagelog %{Accept-Language}>h
access_log /var/log/squid/languages.log languagelog
error_directory /share/squid/errors/pt-br
# Cache
cache_dir aufs /var/cache/squid 10240 16 256
coredump_dir /var/spool/squid
maximum_object_size 5 GB
minimum_object_size 0 KB
cache_swap_low 90
cache_swap_high 95
#acl QUERY urlpath_regex cgi-bin \?
#cache deny QUERY
refresh_pattern -i squid\.internal 10080 80% 79900 override-lastmod override-expire ignore-reload ignore-no-store ignore-must-revalidate ignore-private ignore-auth
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
#refresh_pattern -i \.(mp3|mp4|m4a|exe|avi|wmv|flv|rar|zip)$ 10080 90% 999999 ignore-no-cache override-expire ignore-private
refresh_pattern -i \.(jpeg|jpg)$ 10080 90% 999999 ignore-no-cache override-expire ignore-private
refresh_pattern -i \.(flv|x-flv|mov|avi|qt|mpg|mpeg|swf|wmv|mp3|mp4|m4a|exe|rar|zip)$ 10080 90% 999999 override-expire override-lastmod reload-into-ims ignore-reload ignore-no-cache ignore-auth ignore-private store-stale
# Network ACL
acl localnet src 10.0.0.0/30 # RFC 1918 possible internal network
acl localnet src 192.168.137.0/24 # RFC 1918 possible internal network
acl localnet src 192.168.1.0/24 # RFC 1918 possible internal network
acl localnet src 192.168.10.0/24 # RFC 1918 possible internal network
acl localnet src fc00::/7 # RFC 4193 local private network range
acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
acl localnet src 192.168.20.0/24
acl localnet src 192.168.30.0/24
#***************************Inicio da configuração para cache de video*****************************************
url_rewrite_program /usr/local/bin/simplerewrite
acl rewritedoms dstdomain .dailymotion.com .video-http.media-imdb.com .dl.sourceforge.net .prod.video.msn.com .c.youtube.com av.vimeo.com .ytimg.com .vid.ec.dmcdn.net .videoslasher.com .googlevideo.com .s.youtube.com .fbcdn.net .akamaihd.net vl.mccont.com .mais.uol.com.br .streaming.r7.com
#acl youtube dstdomain .youtube.com
acl yt url_regex -i googlevideo.*videoplayback
acl gmaps url_regex -i ^https?:\/\/(khms|mt)[0-9]+\.google\.[a-z\.]+\/.*
acl ttv url_regex -i terratv
acl globo url_regex -i ^http:\/\/voddownload[0-9]+\.globo\.com.*
acl dm url_regex -i dailymotion\-flv2
acl getmethod method GET
#********************BLOQUEIO DE CONTEÚDO INDESEJAVEIS***************************
acl palavras_bloqueadas url_regex -i "/etc/squid/regras/palavras_bloqueadas.txt"
acl sites_bloqueados url_regex -i "/etc/squid/regras/sites_bloqueados.txt"
range_offset_limit none
quick_abort_min -1 KB
#cache allow youtube
store_id_program /usr/local/bin/hsc-dynamic-cache -file /usr/local/etc/hsc-dynamic-cache-db.txt
store_id_extras "%>a/%>A %un %>rm myip=%la myport=%lp referer=%{Referer}>h"
store_id_children 40 startup=10 idle=5 concurrency=0
store_id_access deny !getmethod
store_id_access allow rewritedoms
store_id_access allow yt
store_id_access allow gmaps
store_id_access allow ttv
store_id_access allow globo
store_id_access allow dm
store_id_access deny all
#refresh_pattern -i ^http://(youtube|ytimg|vimeo|[a-zA-Z0-9\-]+)\.squid\.internal 10080 80% 79900 override-lastmod override-expire ignore-reload ignore-no-store ignore-must-revalidate ignore-private ignore-auth
# Port ACL
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rync
acl Safe_ports port 80 8080 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # 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 purge method PURGE
acl CONNECT method CONNECT
# Authentication
# Uncomment the following lines to enable file based authentication BUT:
# The following section requires to have squid libs installed, especially `nsca_auth`, to be working.
# This sections uses a Htpasswd file named `users.pwd` file to store eligible accounts.
# You can generate yours at http://www.htaccesstools.com/htpasswd-generator/
#auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/users.pwd
#auth_param basic children 5
#auth_param basic realm Proxy
#auth_param basic credentialsttl 2 hours
#acl users proxy_auth REQUIRED
#acl auth proxy_auth REQUIRED
# ADMINISTRATIVE PARAMETERS
# -----------------------------------------------------------------------------
cache_mgr ******
cache_effective_user proxy
cache_effective_group proxy
httpd_suppress_version_string on
visible_hostname *****
#http_access allow users
# Access Restrictions
cache allow rewritedoms
cache allow yt
cache allow gmaps
cache allow ttv
cache allow globo
cache allow dm
cache allow localnet
http_access allow manager localhost
http_access allow manager localnet
#http_access allow youtube
http_access allow rewritedoms
http_access allow yt
http_access allow gmaps
http_access allow ttv
http_access allow globo
http_access allow dm
#*********************BLOQUEIO DE SITES INDESEJAVEIS*********************
http_access deny palavras_bloqueadas
http_access deny sites_bloqueados
http_access deny manager
http_access allow purge localhost
http_access deny purge
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow localnet
http_reply_access allow all
htcp_access allow all
icp_access allow all
always_direct allow all
# Request Headers Forcing
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all
# Response Headers Spoofing
reply_header_access Via deny all
reply_header_access X-Cache deny all
reply_header_access X-Cache-Lookup deny all
#bin/bash
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -F
iptables -X
iptables -t nat -F
iptables -t mangle -F
iptables -t mangle -X
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
#******************LIBERANDO PORTAS SSH A PARTIR DE QUALQUER INTERFACE DE REDE*********************
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
#******************LIBERANDO PORTAS SQUID, HTTP E NTP. ESTES SERVIçOS O FIREWALL SÓ IRÁ RESPONDER**************
#*****************SE VIEREM DA INTERFACE DA REDE INTERNA. AQUI DEVE-SE APLICAR A REGRA DE ACORDO COM O CENÁRIO***
iptables -A INPUT -p tcp --dport 3128 -i eth0 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -i eth0 -j ACCEPT
iptables -A INPUT -p tcp --dport 21 -i eth0 -j ACCEPT
iptables -A INPUT -p tcp --dport 123 -i etho -j ACCEPT
iptables -A INPUT -p udp --dport 123 -i etho -j ACCEPT
#*****************NAT GLOBAL - MASCARAMENTO PARA COMPARTILHAR INTERNET COM OUTRA INTERFACE. OBS.: TEM QUE TER DUAS PLACAS DE REDE************
#*****************ETH0 É A MINHA PLACA CONECTADA A INTERNT. EU DEVO APLICAR A REGRA NAT NELA*************************
#iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#******************NAT PARA SUBREDE ESPECIFICA. NESSE CASO VAMOS COMPARTILHAR INTERNET ESPECIFICANDO A SUBREDE POR CLASSE DE IP****************
#******************EXEMPLO DE SUBREDE*************************************
#iptables -t nat -A POSTROUTING -s 192.168.20.0/24 -o eth0 -j MASQUERADE
#************CONFIGURANDO********************************
#iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 10.0.0.0/29 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.20.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -s 192.168.30.0/24 -o eth0 -j MASQUERADE
#*********************REDIRECIONANDO TRÁFEGO DA PORTA 80 PARA O SQUID - PORTA 3128********************************
iptables -t nat -A PREROUTING -s 10.0.0.0/29 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -s 192.168.20.0/24 -p tcp --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -s 192.168.30.0/24 -p tcp --dport 80 -j REDIRECT --to-port 3128
#*********************REDIRECINANDO TRÁFEGO DA PORTA 443 PARA O SQUID - PORTA 3128*********************************
#iptables -t nat -A PREROUTING -s 192.168.10.0/24 -p tcp --dport 443 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -s 10.0.0.0/29 -p tcp --dport 443 -j REDIRECT --to-port 3130
iptables -t nat -A PREROUTING -s 192.168.20.0/24 -p tcp --dport 443 -j REDIRECT --to-port 3130
iptables -t nat -A PREROUTING -s 192.168.30.0/24 -p tcp --dport 443 -j REDIRECT --to-port 3130