Menu

#1724 Block images and scripts based on referer

3.0.15
open
nobody
5
2018-03-12
2018-02-27
P. Zaccaria
No

Hi,
I would like to block some images or scripts only on some domains (facebook like-buttons for example).

I know that I could achieve this by filters, but since https is now almost everywhere, this is no longer possible.

I was thinking to a workaround by using taggers.
Let’s say I want to block .facebook.com only if the referer is .referrer.net.
Is this possible? Has anybody managed in doing something like that and how?

I think I should have something like this in user.action:

+client-header-tagger{referer}
/

+block{test}
TAG:referrer.net$
.facebook.com

But this blocks .facebook.com everywhere.
How should the code look?

Discussion

  • Fabian Keil

    Fabian Keil - 2018-03-08

    To do what you want you have to create a custom tagger
    that is enabled for all facebook requests and tags all
    request with the referer you want to block.

     
  • P. Zaccaria

    P. Zaccaria - 2018-03-12

    What do you mean with “to create a custom tagger”. Anything like that in user.filter?

    CLIENT-HEADER-TAGGER: fb-request
    s@some-facebook-pattern-in-header@FB-pattern@

    And then how should the user.action look, to block facebook only on referrer.net.
    Something like this?

    +block{facebook}
    TAG: FB-pattern
    TAG: referrer.net

    And in default.action:
    {
    +client-header-tagger{referer}
    +client-header-tagger{fb-request}
    }
    /

     
    • Fabian Keil

      Fabian Keil - 2018-03-14

      "P. Zaccaria" pzac@users.sourceforge.net wrote:

      What do you mean with “to create a custom tagger”. Anything like that in
      user.filter?

      CLIENT-HEADER-TAGGER: fb-request
      s@some-facebook-pattern-in-header@FB-pattern@

      Yes.

      And then how should the user.action look, to block facebook only on
      referrer.net. Something like this?

      +block{facebook}
      TAG: FB-pattern

      TAG:^FB-Pattern$

      TAG: referrer.net

      You don't need this.

      And in default.action:
      {
      +client-header-tagger{referer}
      +client-header-tagger{fb-request}
      }
      /

      the fb-request tagger should only be enabled for facebook requests.

      Fabian

       

Log in to post a comment.

MongoDB Logo MongoDB