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

    Configurar squid numa interface autenticado e na outra transparent

    Scheduled Pinned Locked Moved Portuguese
    34 Posts 6 Posters 6.1k 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.
    • I Offline
      isaiasbertin
      last edited by

      se desabilitar uma da autenticação pois tem uma função na aba autenticação que tira a rede da autenticação ai trabalhar com os bloqueios manual para aquela rede

      o que vc acha Tomas

      1 Reply Last reply Reply Quote 0
      • T Offline
        tomaswaldow
        last edited by

        Não tem como separar. Eu virtualizaria e criaria uma instancia para cada autenticação.

        Tomas @ 2W Consultoria

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

          Acho que você terá que criar uma outra instância do squid. Fiz isso em lab e funcionou, só q no caso usei uma interface pra WPAD e outra pra Captive portal (com squid). A ideia é a mesma.

          +- assim:

          1-No GUI, configura a interface transparente e salva o squid.conf via console. Ex: squid-lab.conf
          2-Muda as configs de 1 pra wpad e reconfigure.
          3- Volte na opção 1(via console) e mude as configurações do arquivo salvo.
          troque:

          • http_port 127.0.0.1:3128 por IP_INTERFACE:3128
          • pid_filename /var/run/squid/squid-lab.conf
          • acl localnet src REDE/MASK 127.0.0.1/8
          • acl allow_subnets src REDE/MASK

          4 - Suba a nova instância:

          /usr/local/squid -k reconfigure -f /usr/local/etc/squid/squid-lab.conf

          Obs:  nos testes que fiz mantive o access.log e o cache.log para as duas instancias do squid. Dessa forma consegui ver os acessos em tempo real na gui.

          1 Reply Last reply Reply Quote 0
          • I Offline
            isaiasbertin
            last edited by

            rlrobs sera que consigo trabalhar com squidguard junto a esta interface também

            vou tentar fazer isso pois é uma rede visitante pois queria proteger contra as pornografias, mas como os celulares não trabalhão com wpad ai deve ficar configurndo e tal

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

              isaiasbertin,

              sim. Nos testes que fiz o squidGuard funcionou sem problemas cmo as duas instâncias do squid

              1 Reply Last reply Reply Quote 0
              • I Offline
                isaiasbertin
                last edited by

                rlrobs fiz o teste e deu certo mesmo, sera que pode dar algum problema com cache do squid memoria essas coisa sera que não é melhor separar ate o cache na outra instancia e deixar somente os logs

                o que vc ache caro.

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

                  Acredito q se der problema é com o cache.log e access.log, mas não coloquei em produção ainda pra ver o resultado. Coloca em produção aí pra gente ver. Se der problema separa os arquivos.

                  1 Reply Last reply Reply Quote 0
                  • I Offline
                    isaiasbertin
                    last edited by

                    agora tenho que colocar na inicialização somente e ver no que vai dar

                    1 Reply Last reply Reply Quote 0
                    • I Offline
                      isaiasbertin
                      last edited by

                      cara  nos teste que fiz tinha alguma coisa de script wpad ativo ainda
                      ai configurei uma outra maquina para testar o squid na segunda interface se eu comfigurar o cara no navedor o squid funciona a segunda instancia mas não como transparente

                      vou mandar o meu arquivo de conf  acho que tem alguma coisa no pf para redirecionar a porta

                      
                      # This file is automatically generated by pfSense
                      # Do not edit manually !
                      
                      http_port 192.168.10.1:3128 
                      http_port 172.0.0.1:3128 intercept
                      icp_port 0
                      dns_v4_first on
                      pid_filename /var/run/squid/squidvisitante.pid
                      cache_effective_user proxy
                      cache_effective_group proxy
                      error_default_language pt-br
                      icon_directory /usr/pbi/squid-amd64/local/etc/squid/icons
                      visible_hostname pfsense.bertin.local
                      cache_mgr isaias@mastercomp.com.br
                      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 off
                      pinger_program /usr/pbi/squid-amd64/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.10.0/24
                      forwarded_for on
                      httpd_suppress_version_string on
                      uri_whitespace strip
                      
                      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 1000 16 256
                      offline_mode off
                      cache_swap_low 90
                      cache_swap_high 95
                      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 9999 3128 3129 1025-65535 
                      acl sslports port 443 563 9999 
                      
                      # 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.10.0/24
                      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
                      
                      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
                      
                      # Package Integration
                      url_rewrite_program /usr/pbi/squidguard-devel-amd64/bin/squidGuard -c /usr/pbi/squidguard-devel-amd64/etc/squidGuard/squidGuard.conf
                      url_rewrite_bypass off
                      url_rewrite_children 16 startup=8 idle=4 concurrency=0
                      
                      # Custom options before auth
                      
                      # 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
                      
                      

                      este é meu arquivo

                      cara acredito que falta redirecionar a porta para o squid no pf.conf

                      1 Reply Last reply Reply Quote 0
                      • I Offline
                        isaiasbertin
                        last edited by

                        caros colegas nos meus teste acho que esta faltando no Pocket filter o direcionamento da porta para o squid transparente na segunda interface
                        pois se configurar no navegado funciona

                        sera que alguém tem uma idéia se consigo direcionar o proxy nas configurações da interface ou se posso adicionar esta regra direto no pocket filter

                        e qual seria o comando.

                        pessoa uma ajuda para os colegas

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

                          Você criou um arquivo  de configuração pra cada instância squid?  Você quer isso aqui mesmo ?
                          http_port 192.168.10.1:3128
                          http_port 172.0.0.1:3128 intercept

                          1 Reply Last reply Reply Quote 0
                          • I Offline
                            isaiasbertin
                            last edited by

                            sim tenho um para cada instancia, este aquivo é fruto da configuração.
                            primeiro selecionei as interfaces no ambiente web e gerei o arquivo, então escolhi a interface rede_visitante e selecionei ele como proxy transparente ai gerou este arquivo fiz a copia dele de squid.conf para squidvisitante.conf e montei a segunda instancia do squid com este arquivo.

                            deu certo a instancia mas não funcionou  como transparente por isso acho que não criou a regra no pocket filter, pois se configurar na mão navega se não não navega, cara fiz de tudo deixei so a esta :

                            http_port 192.168.10.1:3128 tirei esta  http_port 172.0.0.1:3128 intercept
                            coloquei assim http_port 192.168.10.1:3128 tranparent
                            tentei assim http_port 192.168.10.1:3128 intercept e por ultimo so esta http_port 192.168.10.1:3128

                            não navega transparente tem uma ideia? sabes como adicionar uma regra pocket filter para proxy transparente iria tentar isso

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

                              Você nao pode fazer isso aqui na instância:

                              http_port 192.168.10.1:3128
                              http_port 172.0.0.1:3128 intercept

                              Ou é transparente (intercept) ou proxy ativo.

                              Crie um squid.conf agrupado por tipo de instância. Ex:

                              squid-lab.conf
                              http_port 192.168.10.1:3128

                              squid.conf
                              http_port 172.0.0.1:3128 intercept

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

                                Vendo tentando fazer essa configuração, mas sem sucesso.
                                Quem conseguiu fazer funcionar poderia fazer um tutorial!?
                                Desde já agradeço.
                                Att.
                                Gerardo Coelho

                                1 Reply Last reply Reply Quote 0
                                • I Offline
                                  isaiasbertin
                                  last edited by

                                  Quando ativo o proxy transparente na interface funciona e copio o arquivo ele sempre gera assim
                                  http_port 192.168.10.1:3128
                                  http_port 127.0.0.1:3128 intercept

                                  O endereço de rede mais a  loopback
                                  Pessoal desculpem coloquei errado é a loopback

                                  Se configurar no navegador funciona quer dizer que o arquivo do squid está OK mais no meu ponto de vista está faltando a entrada PF o encaminhamento para porta 80 para o squid trabalhar transparente

                                  Quem sabe solicitar ajuda para o Marcello ou Jack

                                  Mas vamos lá vamos descobrir como colocar esta entrada no PF o firewall

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

                                    Seguinte… acabei de refazer os testes e só funcionou quando eu deixei a instância padrão (configurada via webgui) como transparente e a segunda instância como autenticada. Segue os arquivos de configuração de cada.

                                    Instancia padrão squid.conf e transparente. (Deve ser configurada no webgi)

                                    
                                    # This file is automatically generated by pfSense
                                    # Do not edit manually !
                                    
                                    http_port 10.40.0.1:3128
                                    http_port 127.0.0.1:3128 intercept
                                    icp_port 0
                                    dns_v4_first on
                                    pid_filename /var/run/squid/squid.pid
                                    cache_effective_user squid
                                    cache_effective_group proxy
                                    error_default_language en
                                    icon_directory /usr/local/etc/squid/icons
                                    visible_hostname proxy
                                    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 0
                                    debug_options rotate=0
                                    shutdown_lifetime 3 seconds
                                    # Allow local network(s) on interface(s)
                                    acl localnet src  10.40.0.0/16
                                    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
                                    
                                    offline_mode off
                                    cache_swap_low 90
                                    cache_swap_high 95
                                    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  
                                    
                                    # 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 10.40.0.0/16
                                    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
                                    
                                    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
                                    
                                    # Package Integration
                                    url_rewrite_program /usr/local/bin/squidGuard -c /usr/local/etc/squidGuard/squidGuard.conf
                                    url_rewrite_bypass off
                                    url_rewrite_children 16 startup=8 idle=4 concurrency=0
                                    
                                    # Custom options before auth
                                    
                                    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
                                    
                                    

                                    Segunda instância. proxy ativo (configurada apenas via cli)
                                    Obs: estou usando autenticação com o AD. lembre-se de trocar as redes.

                                    
                                    # This file is automatically generated by pfSense
                                    # Do not edit manually !
                                    #squid autenticado
                                    
                                    http_port 10.20.0.1:3128
                                    #http_port 127.0.0.1:3128
                                    icp_port 0
                                    dns_v4_first on
                                    pid_filename /var/run/squid/squid-auth.pid
                                    cache_effective_user squid
                                    cache_effective_group proxy
                                    error_default_language en
                                    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 0
                                    debug_options rotate=0
                                    shutdown_lifetime 3 seconds
                                    # Allow local network(s) on interface(s)
                                    acl localnet src  10.20.0.0/16 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
                                    
                                    offline_mode off
                                    cache_swap_low 90
                                    cache_swap_high 95
                                    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 8443 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 10.20.0.0/16
                                    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
                                    
                                    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
                                    
                                    # Package Integration
                                    url_rewrite_program /usr/local/bin/squidGuard -c /usr/local/etc/squidGuard/squidGuard.conf
                                    url_rewrite_bypass off
                                    url_rewrite_children 16 startup=8 idle=4 concurrency=0
                                    
                                    # Custom options before auth
                                    
                                    acl sglog url_regex -i sgr=ACCESSDENIED
                                    auth_param basic program /usr/local/libexec/squid/basic_ldap_auth -v 3 -b dc=ifg,dc=teste -D cn=Administrator,cn=Users,dc=ifg,dc=teste -w 123456 -f "sAMAccountName=%s" -u uid -P 10.30.0.10:389
                                    auth_param basic children 5
                                    auth_param basic realm Please enter your credentials to access the proxy
                                    auth_param basic credentialsttl 5 minutes
                                    acl password proxy_auth REQUIRED
                                    # Custom options after auth
                                    
                                    http_access deny password sglog
                                    http_access allow password localnet
                                    http_access allow password allowed_subnets
                                    # Default block all to be sure
                                    http_access deny allsrc
                                    
                                    

                                    Script de inicialização da segunda instância. (iniciará no boot)
                                    Pf 2.3: /usr/local/etc/rc.d/check_squid-auth.sh

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

                                    Dessa forma ai eu consegui fazer funcionar.

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

                                      No meu caso preciso usar uma instancia como transparente para rede wifi com captive portal ( autenticacao e vouchers)
                                      E a outra instancia proxy ativo para rede dos funcionários.
                                      Preciso pegar os logs de acesso das duas redes.
                                      Você testou se esta pegando os logs de acesso das duas redes?

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

                                        Pra integrar o captive ao squid vc tem q trocar o script check_ip.sh pq o original tem bug. Depois posto o script q funciona aqui ,mas se quiser adiantar da uma pesquisada aqui no fórum em português… tem um colega q postou um  script q funciona.

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

                                          Vou ver…
                                          testou se esta pegando os logs de acesso das duas redes?
                                          Eu uso aqui o LogSquid, muito bom por sinal.

                                          1 Reply Last reply Reply Quote 0
                                          • I Offline
                                            isaiasbertin
                                            last edited by

                                            Nós meus teste aparece na interface web os logs do squid das duas redes.

                                            Vou fazer os teste que nosso colega passou
                                            Ai passo para vcs

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