Enviado em 03/08/2015 - 10:05h
Bom dia Galera. Estou começando agora a montar o meu Squid. Não tenho tanta familiaridade com o linux e a partir de um ponto aqui não estou conseguindo mais prosseguir.
# MENSAGENS DE ERRO EM PORTUGUES
error_directory /usr/share/squid3/errors/pt-br
# PORTA DO SQUID
http_port 3128 transparent
# NOME DO SERVIDOR
visible_hostname empresa-proxy
# CACHE
cache_mem 600 MB
maximum_object_size_in_memory 64 KB
maximum_object_size 512 MB
minimum_object_size 0 KB
cache_swap_low 90
cache_swap_high 95
cache_dir ufs /var/spool/squid3 45000 16 256
cache_access_log /var/log/squid3/access.log squid
cache_mgr email@email.com.br
memory_pools off
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
quick_abort_max 16 KB
quick_abort_pct 95
quick_abort_min 16 KB
request_header_max_size 20 KB
reply_header_max_size 20 KB
request_body_max_size 0 KB
# REGRAS ACL PADRAO
#acl all src 0.0.0.0/0.0.0.0
#acl manager proto cache_object #NAO SE USA MAIS NO SQUID3
#acl localhost src 127.0.0.1/32
acl SSL_ports port 443 563
acl Safe_ports port 80 # http
acl Safe_ports port 21 # ftp
acl Safe_ports port 443 563 # https, snews
acl Safe_ports port 70 # gopher
acl Safe_ports port 210 # wais
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 901 # swat
acl Safe_ports port 1025-65535 # Portas Altas
acl purge method PURGE
acl CONNECT method CONNECT
# PERMISSOES E BLOQUEIOS PADRAO
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
# DEFINICOES DA REDE
acl redelocal src 192.168.50.0/24
acl diretores src 192.168.50.1 192.168.50.3 192.168.50.19 192.168.50.20 192.168.50.21 192.168.50.12
acl producao src 192.168.50.51 192.168.50.52 192.168.50.53 192.168.50.54 192.168.50.55 192.168.50.56 192.168.50.57 192.168.50.58 192.168.50.59 192.168.50.60
acl extensoes_liberadas urlpath_regex -i \.(rar|zip|doc|xls|exe|gz|pdf|jpe?g|bmp|png|ppt|txt)$
acl extensoes_bloqueadas urlpath_regex -i \.(torrent|avi|mp3|rmvb|iso|dat|bin|com|dll|ini|mpe?g|rar)$
acl palavras_bloqueadas url_regex -i facebook
acl sites_bloqueados url_regex -i www.facebook.com pt-br.facebook.com
# BLOQUEIOS
http_access deny palavras_bloqueadas
http_access deny sites_bloqueados
http_access deny extensoes_bloqueadas
http_access deny producao
# CONTROLE DE BANDA
delay_pools 3
delay_class 1 2
delay_class 2 2
delay_class 3 2
delay_parameters 1 700000/700000 700000/700000 #aprox. 6Mb p/diretores
delay_parameters 2 500000/500000 500000/500000 #aprox. 4Mb p/todos
delay_parameters 3 500000/500000 500000/500000 #aprox. 1Mb p/downloads
delay_access 3 allow extensoes_liberadas
delay_access 3 deny all
delay_access 1 allow diretores
delay_access 1 deny all
delay_access 2 allow redelocal
delay_access 2 deny all
# PERMISSAO REDE LOCAL E SERVIDOR
http_access allow localhost
http_access allow redelocal
# BLOQUEIO DE USUARIOS DE FORA DA REDE
http_access deny all
#!/bin/sh
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ip_tables
modprobe ipt_LOG
modprobe ipt_MARK
modprobe ipt_MASQUERADE
modprobe ipt_REDIRECT
modprobe ipt_REJECT
modprobe ipt_TCPMSS
modprobe ipt_TOS
modprobe ipt_limit
modprobe ipt_mac
modprobe ipt_mark
modprobe ipt_multiport
modprobe ipt_owner
modprobe ipt_state
modprobe ipt_tcpmss
modprobe ipt_tos
modprobe iptable_filter
modprobe iptable_mangle
modprobe iptable_nat
#Dados do servidor
SQUID_SERVER="192.168.50.250"
#Placa de rede do Modem
INTERNET="eth1"
#Endereço da Rede Local
LOCAL="192.168.50.0/24"
#Porta do Squid
SQUID_PORT="3128"
#Limpando regras de antigas de firewall
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
#Habilitando IP Forward
echo 1 > /proc/sys/net/ipv4/ip_forward
#Configurando filtros padrão
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
#Se tornando um roteador para toda a rede
iptables -t nat -A POSTROUTING -o $INTERNET -j MASQUERADE
iptables -A FORWARD -s $LOCAL -j ACCEPT
#Acesso ilimitado ao loopback
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
#Permitir UDP/DNS e FTP PASSIVO
#iptables -A INPUT -i $INTERNET -m state -state ESTABLISHED,RELATED -j ACCEPT
#Acesso ilimitado a rede
iptables -A INPUT -s $LOCAL -j ACCEPT
iptables -A OUTPUT -s $LOCAL -j ACCEPT
#proxy transparente, tratando dos protocolos UDP e TCP - PORTA DA REDE
iptables -t nat -A PREROUTING -s $LOCAL -p tcp --dport 80 -j DNAT --to $SQUID_SERVER:$SQUID_PORT
iptables -t nat -A PREROUTING -i $INTERNET -p tcp --dport 80 -j REDIRECT --to-port $SQUID_PORT
#Permitir tudo e fazer log
iptables -A INPUT -j LOG
iptables -A INPUT -j DROP
#Abrir tudo
iptables -A INPUT -i $INTERNET -j ACCEPT
iptables -A OUTPUT -o $INTERNET -j ACCEPT