Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Squid com múltiplas instancias funcionando

    Scheduled Pinned Locked Moved Portuguese
    3 Posts 2 Posters 916 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      gerardocoelho
      last edited by

      Boa tarde pessoal!

      Resolvi abrir esse tópico em específico, quem sabe daqui surja algum tutorial para os que precisam dessa implementação.
      Venho tentando há mais de uma semana implementar o squid carregando em duas instâncias para duas redes locais, uma com proxy ativo e a outra com proxy transparente, redes diferentes, e até o momento não obtive sucesso.
      Meu cenário é: Duas redes WANS em Load Balance e duas Lans. Uma placa de rede  com proxy ativo para os funcionários da empresa 192.168.1.0/24 e a outra placa de  rede vai para um access point com endereço de rede 10.10.0.0/24.
      Preciso que uma rede funcione em proxy ativo e a outra em proxy transparente, e o mais importante, registrar os acessos das duas redes.
      Se alguém conseguiu na prática, agradeço se puder me ajudar, pois já testei vários tutoriais sem sucesso.
      Desde já agradeço pela atenção.
      Att
      Gerardo Coelho

      1 Reply Last reply Reply Quote 0
      • G
        gerardocoelho
        last edited by

        Boa noite pessoal!
        Depois de muitos testes finalmente consegui.
        Gostaria que pudessem testar e aprimorar. Não sei se é a minha internet que está um pouco lenta agora, mas me pareceu que ficou mais lento com as duas instancias…
        Cenário: 2 WANS + 2 LANS (SENDO UMA COM PROXY ATIVO E A OUTRA PROXY TRANSPARENTE)

        Segue o tutorial:

        Primeiro passo: instalar o squid, fazer as devidas configurações do cache e ativar uma das interfaces LAN como proxy transparente.
        Segundo passo: criar outro arquivo de configuração do squid, no meu caso criei squid3128.conf (configurado como proxy ativo)

        
        # This file is automatically generated by pfSense
        # Do not edit manually !
        
        http_port 192.168.1.1:3128
        #http_port 127.0.0.1:3128
        icp_port 0
        dns_v4_first on
        pid_filename /var/run/squid/squid2.pid
        cache_effective_user squid
        cache_effective_group proxy
        error_default_language pt-br
        icon_directory /usr/local/etc/squid/icons
        visible_hostname localhost
        cache_mgr admin@localhost
        access_log /var/squid/logs/access.log
        cache_log /var/squid/logs/cache.log
        cache_store_log none
        netdb_filename /var/squid/logs/netdb.state
        pinger_enable on
        pinger_program /usr/local/libexec/squid/pinger
        
        logfile_rotate 30
        debug_options rotate=30
        shutdown_lifetime 3 seconds
        # Allow local network(s) on interface(s)
        acl localnet src  192.168.1.0/24 127.0.0.0/8
        forwarded_for on
        uri_whitespace strip
        
        acl dynamic urlpath_regex cgi-bin \?
        cache deny dynamic
        
        cache_mem 64 MB
        maximum_object_size_in_memory 256 KB
        memory_replacement_policy heap GDSF
        cache_replacement_policy heap LFUDA
        minimum_object_size 0 KB
        maximum_object_size 4 MB
        cache_dir ufs /var/squid/cache 100 16 256
        offline_mode off
        cache_swap_low 90
        cache_swap_high 95
        acl donotcache dstdomain "/var/squid/acl/donotcache.acl"
        cache deny donotcache
        cache allow all
        # Add any of your own refresh_pattern entries above these.
        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
        
        #Remote proxies
        
        # Setup some default acls
        # From 3.2 further configuration cleanups have been done to make things easier and safer. The manager, localhost, and to_localhost ACL definitions are now built-in.
        # acl localhost src 127.0.0.1/32
        acl allsrc src all
        acl safeports port 21 70 80 210 280 443 488 563 591 631 777 901  3128 3129 1025-65535 
        acl sslports port 443 563 8443
        
        # From 3.2 further configuration cleanups have been done to make things easier and safer. The manager, localhost, and to_localhost ACL definitions are now built-in.
        #acl manager proto cache_object
        
        acl purge method PURGE
        acl connect method CONNECT
        
        # Define protocols used for redirects
        acl HTTP proto HTTP
        acl HTTPS proto HTTPS
        acl allowed_subnets src 192.168.1.0/24
        acl whitelist dstdom_regex -i "/var/squid/acl/whitelist.acl"
        acl blacklist dstdom_regex -i "/var/squid/acl/blacklist.acl"
        http_access allow manager localhost
        
        http_access deny manager
        http_access allow purge localhost
        http_access deny purge
        http_access deny !safeports
        http_access deny CONNECT !sslports
        
        # Always allow localhost connections
        # From 3.2 further configuration cleanups have been done to make things easier and safer.
        # The manager, localhost, and to_localhost ACL definitions are now built-in.
        # http_access allow localhost
        
        quick_abort_min 0 KB
        quick_abort_max 0 KB
        request_body_max_size 0 KB
        delay_pools 1
        delay_class 1 2
        delay_parameters 1 -1/-1 -1/-1
        delay_initial_bucket_level 100
        delay_access 1 allow allsrc
        
        # Reverse Proxy settings
        
        # Custom options before auth
        
        # Always allow access to whitelist domains
        http_access allow whitelist
        # Block access to blacklist domains
        http_access deny blacklist
        acl sglog url_regex -i sgr=ACCESSDENIED
        http_access deny sglog
        # Setup allowed ACLs
        # Allow local network(s) on interface(s)
        http_access allow allowed_subnets
        http_access allow localnet
        # Default block all to be sure
        http_access deny allsrc
        
        

        Terceiro passo: Criar em /var/run/squid/  o arquivo "squid2.pid"  (sem aspas) <<<–- arquivo em branco, sem nada dentro
        Quarto passo: Criar em /usr/local/etc/    o arquivo "squid3128.sh" (sem aspas)  <<<--- nome que escolhi
        Quinto passo: chmod +x squid3128.sh  <<<--- para dar permisso ao script ser executado
        Código do script squid3128:

        
        #!/bin/sh
        
        /bin/ps ax | /usr/bin/grep /usr/local/etc/squid/squid3128.conf | /usr/bin/grep -v grep
        if [ $? -eq 0 ];then
            /bin/echo ok
        else
            /usr/local/sbin/squid -f /usr/local/etc/squid/squid3128.conf
        fi
        
        

        Feito isso é só reiniciar…
        No meu caso funcionou, só queria que alguém testasse porque achei lento o acesso a internet, não sei se foi coincidência que minha net tava lenta.

        Obs: Lembrando que após essa configuração, qualquer mudança no squid pela pagina do pfsense (webguia), poderá por em risco o funcionamento do squid. Portanto após isso se precisar fazer alguma configuração, usem o shell.

        Espero ter ajudado.
        Att.
        Gerardo Coelho

        1 Reply Last reply Reply Quote 0
        • R
          rlrobs
          last edited by

          E ai gerardocoelho, colocou em produção? Eu ainda to fazendo testes e nao entendi pq só funciona se o proxy ativo for a segunda instância (criada no shell). Se for o contrário (transparente criada no shell), os logs nao sao registrados. Você realizou esse teste?

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.