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

    Squidguard: how to redirect each category to it's URL?

    Scheduled Pinned Locked Moved pfSense Packages
    5 Posts 3 Posters 3.8k 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.
    • K
      KiFFuSeR
      last edited by

      How to redirect each Target Category to a unique URL?

      Example:

      For destination [blk_BL_adv] I want to redirect to External URL http://MyWebServer/blockedADV.html

      For destination [blk_BL_porn] I want to redirect to External URL http://MyWebServer/blockedPORN.html

      I can achieve this in a regular squidguard setup (non pfSense) by using the folowing in squidguard.conf:

      
      dest blk_BL_adv {
              domainlist blk_BL_adv/domains
              urllist blk_BL_adv/urls
              log block.log
              redirect http://MyWebServer/blockedADV.html
      }
      
      dest blk_BL_porn {
              domainlist blk_BL_porn/domains
              urllist blk_BL_porn/urls
              log block.log
              redirect http://MyWebServer/blockedPORN.html
      }
      
      

      Is this possible in pfSense's Squidguard package?

      1 Reply Last reply Reply Quote 0
      • D
        dvserg
        last edited by

        Via GUI not possible

        SquidGuardDoc EN  RU Tutorial
        Localization ru_PFSense

        1 Reply Last reply Reply Quote 0
        • K
          KiFFuSeR
          last edited by

          can you detail how to do it via shell?

          I tried to manually edit squidguard.conf, but after a save/apply in Web-GUI my changes go away because the file is always rebuilt.

          How can I make the changes persistent?

          1 Reply Last reply Reply Quote 0
          • marcellocM
            marcelloc
            last edited by

            You may need to edit squidguard.inc.
            Normally package_name.inc is the file That generates conf files.

            Treinamentos de Elite: http://sys-squad.com

            Help a community developer! ;D

            1 Reply Last reply Reply Quote 0
            • K
              KiFFuSeR
              last edited by

              I've been looking in squidguard_configurator.inc where I think the function sg_create_config() is what generates the squidguard conf.

              I've altered the section related to the destinations:

                  # --- Destinations ---
                  if ($squidguard_config[F_DESTINATIONS]) {
                      $temp_str = '';
                      foreach($squidguard_config[F_DESTINATIONS][F_ITEM] as $dst) {
                          $dstname = $dst[F_NAME];
                          $sg_tag->clear();
                          $sg_tag->set("dest", $dst[F_NAME], "", $dst[F_DESCRIPTION]);
              
                          if ($dst[F_DOMAINS])
                              $sg_tag->items[] = "domainlist $dstname/domains";
                          if ($dst[F_EXPRESSIONS])
                              $sg_tag->items[] = "expressionlist $dstname/expressions";
                          if ($dst[F_URLS])
                              $sg_tag->items[] = "urllist $dstname/urls";
                          if ($dst[F_RMOD] != RMOD_NONE)
                              $sg_tag->items[] = "redirect " . sg_redirector_base_url($dst[F_REDIRECT], $dst[F_RMOD]);
                          if ($squidguard_config[F_ENABLELOG] == 'on' ) {
                              if ($dst[F_LOG])
                                  $sg_tag->items[] = "log " . SQUIDGUARD_LOGFILE;
                          }
              
              [b]	    if ($dst[F_NAME] == 'blk_BL_adv')			
              		  $sg_tag->items[] = "redirect http://MyWebServer/blockedADV.html";	
              [/b]
              
                          $sgconf[] = "";
                          $sgconf[] = $sg_tag->tag_text();
              
                          # log
                          $temp_str .= " $dstname;";
                      }
                      # log
                      $temp_str = !empty($temp_str) ? $temp_str : "Nothing.";
                      sg_addlog("sg_create_config", "Add destinations: $temp_str", SQUIDGUARD_INFO);
                  }
              

              I've just added the part in bold, but this could not generate the directive in the squidguard config to redirect destination blk_BL_adv.

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