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



  • 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?



  • Via GUI not possible



  • 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?



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



  • 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.


Log in to reply