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

    Issues with "Log Pages Denied by SquidGuard", again

    Scheduled Pinned Locked Moved Cache/Proxy
    5 Posts 3 Posters 6.5k 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.
    • S
      siz
      last edited by siz

      I'm currently trying to log denied SquidGuard requests at Services -> Squid Proxy Server -> General. I've checked Log Pages Denied by SquidGuard. I'm now wanting to add some code to sgerror.php to allow the logging to work. The hint says:

      Important: This option will only work if you include the code below in your sgerror.php file.
      This forces the client browser to send a second request to Squid with the denied string in URL.
      
      $sge_prefix = (preg_match("/\?/", $cl['u']) ? "&" : "?");
      $str[] = '< iframe > src="'. $cl['u'] . $sge_prefix . 'sgr=ACCESSDENIED" width="1" height="1" > < /iframe >';
      
      Hint: You MUST remove extra spaces in the above iframe HTML tags.
      

      Where do I add this code to sgerror.php (copy of file attached: sgerror.php.txt)?

      I know this has been covered before but none of the answers I could find online are relevant to pfSense v2.4.5.

      K 1 Reply Last reply Reply Quote 1
      • K
        kasalencar @siz
        last edited by

        @siz said in Issues with "Log Pages Denied by SquidGuard", again:

        sgerror.php.txt

        Segue um arquivo customizado.
        Abra seu arquivo atual via WebGui
        Diagnostics -> Edit File
        abra o arquivo sgerror.php

        Substitua o conteúdo completo por esse arquivo Customizado
        sgerror.txt

        1 Reply Last reply Reply Quote 1
        • JonathanLeeJ
          JonathanLee
          last edited by JonathanLee

          I think after

          	<?php if ($cl['u']): ?>
          		<b> URL:            </b> <?= htmlspecialchars($cl['u']) ?><br/>
          

          Make it ...

          	<?php if ($cl['u']): ?>
          		<b> URL:            </b> <?= htmlspecialchars($cl['u']) ?><br/>
                      <?php 
                          $sge_prefix = (preg_match("/\?/", $cl['u']) ? "&" : "?");
                          $str = '<iframe> src="'. $cl['u'] . $sge_prefix . 'sgr=ACCESSDENIED" width="1" height="1"> </iframe>';
          	     ?>
                        <?= $str ?>
                     <?php endif; ?>
                           
          		<hr size="1" noshade>
          	</body>
          

          Ref:
          https://forums.phpfreaks.com/topic/313731-need-assistance-with-placement-of-code-for-php-script/

          Make sure to upvote

          1 Reply Last reply Reply Quote 0
          • JonathanLeeJ
            JonathanLee
            last edited by JonathanLee

            Make sure ..

            "Hint: You MUST remove extra spaces in the above iframe HTML tags."

            $sge_prefix = (preg_match("/?/", $cl['u']) ? "&" : "?");
            $str[] = '<iframe> src="'. $cl['u'] . $sge_prefix . 'sgr=ACCESSDENIED" width="1" height="1"></iframe>';

            But it makes an array,, let me test more

            Make sure to upvote

            1 Reply Last reply Reply Quote 0
            • JonathanLeeJ
              JonathanLee
              last edited by

              Screenshot 2023-12-22 at 8.20.54 PM.png

              This seems to work but the logs do not say ACCESSDENIED

              Make sure to upvote

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