Results 1 to 6 of 6

Thread: To Block Ads And Banners In SafeSquid Proxy Server

  1. #1
    Join Date
    Feb 2009
    Posts
    66

    To Block Ads And Banners In SafeSquid Proxy Server

    hi,

    I am using SafeSquid proxy server. However, everything is fine with this
    but unwanted ads and banners are really troublesome and distracting.
    I want to get rid from this....
    My question is how can I block this permanently ? Any ideas ..... please suggest

  2. #2
    Join Date
    Apr 2008
    Posts
    3,424

    Re: To Block Ads And Banners In SafeSquid Proxy Server

    You can replace ads and banners with a custom html page. This requires configuring 3 sections, viz. Templates, Profiles and URL redirecting.

    The first thing to do is to design an html page, to replace the ads and banners. Since many ads and banners are displayed in a small window, the html page that you design to replace them, should be as small as possible.

    Here is a sample :
    Code:
    <table border="0" cellspacing="0" width="100" cellpadding="0" bgcolor="#00FFFF">
     <tr>
     <td>
     <p align="center"><font size="1" face="Tahoma"><a href="http://www.safesquid.com/">Ad / banner blocked<br>
     &nbsp;by <b>SafeSquid</b></a></font></td>
     </tr>
     </table>
    Copy your custom html file, which we will call ads.html in this tutorial, to the SafeSquid template directory. By default, the directory is located at /opt/safesquid/safesquid/templates/. You can verify this from the SafeSquid Interface => Config => Templates Section.

  3. #3
    Join Date
    Apr 2008
    Posts
    3,424

    Re: To Block Ads And Banners In SafeSquid Proxy Server

    SafeSquid's Templates section, allows you to add your own custom templates, or messages, to be displayed when a page is blocked by a filter, instead of SafeSquid's default message. The replacement file could be an html page, an image, audio / video file, an executable, etc. and is a very powerful tool, that we will explained in a future tutorial.

    After you have copied the file to the templates directory, you need to define the file in the Templates section (create a template), and give it a name by which it will be identified in the other section. To do this, open the SafeSquid Interface and go to Config => Templates. Click on Add under the Template sub-section and add the new template.

    Now the file ads.html can be used as a template in SafeSquid, and has been named replace-ad-banner. We will later use it in the URL Redirecting section.

    The next thing to do, is to identify ads and banners that appear in web pages, so that they can be replaced. They could either be fetched from a remote Ad Server, or located on the same web server. In the former case, if the Ad Servers are identified, then it would be easy to identify the content being fetched by these servers. In the later case, in most cases, the link to the content has the words ad, ads, adv, advert, banner, banners, etc. in the file part of the URL, e.g. d7.zedo.com/ads2/*, *.googlesyndication.com/pagead/show_ads.js. So, if we can filter our such URLs, we can replace them with our custom template.

  4. #4
    Join Date
    Apr 2008
    Posts
    3,339

    Re: To Block Ads And Banners In SafeSquid Proxy Server

    SafeSquid allows the use of Perl Compatible Regular Expressions (PCRE), hence we can create a single rule that can cover multiple words, strings or expressions.
    Go to Config => Profiles and create the following two rules:

    RULE - 1
    This rule analyzes the Host part of URLs to verify if the content is being served from any of the Ad Servers listed in the Host field, and if a positive mach is found, applies the profile Ad-Server-Content to that content.

    The Host field in the above rule is a regular expression. Host names are separated with a pipe (|). In regular expressions, a '.' is a special character - a single character wildcard. A '\' before a '.' specifies that it is to be interpreted as character '.' and not wildcard. The expression begins with ^ad(|s|v|server)\. This will match the expressions ad., ads., adv. and adserver.
    in the host part of a URL, e.g. ad.indiatimes.com, ads.asiafriendfinder.com, adv.elbuscador.com, etc. You can also add additional hosts to the expression.

    RULE - 2
    This rule analyzes the file part of URLs to verify if they contain any of the expressions specified in the file field of the rule, and if a positive match is found, applies the profile Ad-Banner to the content.

    We can now use the added profiles Ad-Server-Content and Ad-Banner that is applied to positive matches, to redirect the requests for them to our custom html page ads.htnl. To achieve this, go to Config => URL redirecting. The URL redirecting section allows you to redirect requests for specific URL, to another URL. This is a very powerful feature, and is mostly used to create redundancy for web servers, when SafeSquid is used in reverse proxy mode.

  5. #5
    Join Date
    Apr 2008
    Posts
    3,339

    Re: To Block Ads And Banners In SafeSquid Proxy Server

    Verify that the section is enabled - Enabled = Yes, click on Add under Redirect sub-section.
    add the following rule:

    Enabled - True

    Comment - Redirect specified profiles to template replace-ad-banner

    Profiles - Ad-Server-Content,Ad-Banner

    URL - /.*

    Redirect - http://safesquid.cfg/template/replace-ad-banner

    Port - 0

    302 redirect - false

    Applies to - both

    Simply put, this rule will redirect all the requests that carry the profiles Ad-Server-Content and Ad-Banner, to the template replace-ad-banner, which is the name of our custom html page - ads.html.

  6. #6
    Join Date
    Jan 2006
    Posts
    3,792

    Re: To Block Ads And Banners In SafeSquid Proxy Server

    You can also verify what URLs are being redirected, by checking the SafeSquid logs.
    Click on View log entries in the Top Menu of the interface. You will see a lot of entries.
    To filter out the entries for URL redirecting, type redirect in the Regular expression match field, and click on Submit.
    This will filter out entries similar to this:

    2008 06 06 13:06:45 [19] redirect: request for http://safesquid.cfg/template/replace-ad-banner

Similar Threads

  1. Internet/Proxy Server
    By V S in forum Software Development
    Replies: 1
    Last Post: 26-07-2011, 12:13 AM
  2. Can I Install Proxy Server on Domain Server
    By vsmishravns in forum Networking & Security
    Replies: 6
    Last Post: 23-07-2011, 07:07 PM
  3. Is there any way to specify a proxy server?
    By Althea in forum Networking & Security
    Replies: 6
    Last Post: 17-04-2011, 10:51 PM
  4. Block Google Talk with Squid proxy firewall
    By LinuxeD in forum Operating Systems
    Replies: 3
    Last Post: 08-08-2009, 01:56 PM
  5. Windows Server 2008 as Proxy Server
    By Auxiliaire Tournée 1 in forum Windows Server Help
    Replies: 6
    Last Post: 03-11-2008, 03:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,802,771.96094 seconds with 16 queries