brunorsantos
(usa Debian)
Enviado em 07/04/2016 - 17:50h
Pessoal, tudo bom com vocês?! Espero que sim...
Já há alguns dias venho tendo dificuldade em bloquear páginas HTTPS como por exemplo o Facebook e Youtube. Já li diversos materiais e sites, uns até dizendo que pelo fato de ter o squid autenticado, ele já faria esse controle de páginas https, porém não deu certo comigo e por isso gostaria de um help de vocês nessa empreitada.
Tenho um Firewall Debian 7.9.0 com Squid 2.7 STABLE 9, fazendo autenticação dos usuários e como disse anteriormente não estou conseguindo bloquear sites https. Já tentei utilizar a solução do nosso colega com o comando iptables -I FORWARD -i eth1 -m string --algo bm --string "facebook.com" -j DROP
porém não deu certo também. Segue os scripts de firewall e squid para vocês poderem dar uma olhada e dar uma dica se possível. Agradeço todo apoio.
Obs.: as máquinas da rede estão utilizando DNS do Google.
http_port 192.168.1.253:3128
visible_hostname fw.com.br
icp_port 0
htcp_port 0
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 512 MB
maximum_object_size 10240 KB
maximum_object_size_in_memory 4 MB
cache_swap_low 90
cache_swap_high 95
cache_dir ufs /var/spool/squid 2048 16 256
cache_access_log /var/log/squid/access.log
access_log /var/log/squid/access.log squid
cache_log /var/log/squid/cache.log
###########AUTENTICACAO#####################################
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_usuarios
auth_param basic children 5
auth_param basic realm Digite seu Login e Senha
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
refresh_pattern (Release|Packages(.gz)*)$ 0 20% 2880
refresh_pattern . 0 20% 4320
cache_replacement_policy lru
memory_replacement_policy lru
################################ACL's############################################
acl all src all
#acl manager proto cache_object
acl localhost src 127.0.0.1/32
acl to_localhost dst 127.0.0.0/8
acl SSL_ports port 443 # https
acl SSL_ports port 563 # snews
acl SSL_ports port 873 # rsync
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
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 Safe_ports port 631 # cups
acl Safe_ports port 873 # rsync
acl Safe_ports port 901 # SWAT
acl auth proxy_auth REQUIRED
acl purge method PURGE
acl CONNECT method CONNECT
acl sites_liberados url_regex -i "/etc/squid/sites_liberados.txt"
acl sites_bloqueados url_regex -i "/etc/squid/sites_bloqueados.txt"
acl ti proxy_auth "/etc/squid/ti.txt"
acl diretoria proxy_auth "/etc/squid/diretoria.txt"
acl teste proxy_auth "/etc/squid3/teste.txt"
acl teste_sites url_regex -i "/etc/squid/teste_sites.txt"
#########################################
## REGRAS HTTP_ACCESS ##
#########################################
http_access allow CONNECT
http_access deny sites_bloqueados
http_access allow sites_liberados
#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
http_access allow localhost
http_access allow ti
http_access allow diretoria
http_access allow teste teste_sites
http_access deny all
error_directory /usr/share/squid/errors/Portuguese
http_reply_access allow all
icp_access allow all
snmp_port 0
coredump_dir /var/spool/squid
#####################################################
Configuração do firewall
#!/bin/bash
# Bloqueando trafego entre interfaces
echo 0 > /proc/sys/net/ipv4/ip_forward
# Carregando modulos basicos
/sbin/modprobe ip_nat_ftp
/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe ip_conntrack_ftp
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_state
/sbin/modprobe ipt_multiport
/sbin/modprobe iptable_mangle
# Zerando regras existentes
iptables -F -t filter
iptables -F -t nat
iptables -F -t mangle
# Definindo politica padrao
iptables -P INPUT DROP
iptables -P OUTPUT DROP
iptables -P FORWARD DROP
# List
iptables -A FORWARD -p tcp --dport 1024:65535 -j ACCEPT
# Basic rules
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -p icmp -j ACCEPT
iptables -A OUTPUT -p icmp -j ACCEPT
iptables -A FORWARD -p icmp -j ACCEPT
# DNS
iptables -A INPUT -p udp --sport 53 -j ACCEPT
iptables -A INPUT -p udp --dport 53 -j ACCEPT
iptables -A INPUT -p tcp --sport 53 -j ACCEPT
iptables -A INPUT -p tcp --dport 53 -j ACCEPT
iptables -A OUTPUT -p udp --sport 53 -j ACCEPT
iptables -A OUTPUT -p udp --dport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 53 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 53 -j ACCEPT
iptables -A FORWARD -p udp --sport 53 -j ACCEPT
iptables -A FORWARD -p udp --dport 53 -j ACCEPT
# Acesso Web FW
iptables -A INPUT -p tcp --sport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 443 -j ACCEPT
iptables -A INPUT -p tcp --sport 443 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 443 -j ACCEPT
# Acesso SQUID
iptables -A INPUT -p tcp -i eth1 --dport 3128 -j ACCEPT
iptables -A OUTPUT -p tcp -o eth1 --sport 3128 -j ACCEPT
# Bloqueio de porta 80 e 443
iptables -A FORWARD -p tcp -s 192.168.1.0/24 --dport 80 -j REJECT
iptables -A FORWARD -p tcp -s 192.168.1.0/24 --dport 443 -j REJECT
iptables -A FORWARD -p tcp -d 192.168.1.0/24 --sport 443 -j REJECT
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.1.0/24 -j MASQUERADE
# Liberando trafego entre interfaces
echo 1 > /proc/sys/net/ipv4/ip_forward