irulan.net

Blocking Facebook Referrers in Nginx

Continuing my series about blocking all things Facebook, here’s how to block Facebook scraping and referrals.

# /usr/local/etc/nginx/faceblock.conf

map $http_referer $facebook_referer {
    default                                          0;
    "~*cdninstagram.com"                             1;
    "~*connect.facebook.net.edgekey.net"             1;
    "~*facebook-web-clients.appspot.com"             1;
    "~*facebook.com"                                 1;
    "~*facebook.net"                                 1;
    "~*fb.com"                                       1;
    "~*fb.me"                                        1;
    "~*fbcdn-profile-a.akamaihd.net"                 1;
    "~*fbcdn.com"                                    1;
    "~*fbcdn.net"                                    1;
    "~*fbsbx.com"                                    1;
    "~*h-ct-m-fbx.fbsbx.com.online-metrix.net"       1;
    "~*instagram.com"                                1;
    "~*instagramstatic-a.akamaihd.net"               1;
    "~*instagramstatic-a.akamaihd.net.edgesuite.net" 1;
    "~*m.me"                                         1;
    "~*messenger.com"                                1;
    "~*profile.ak.facebook.com.edgesuite.net"        1;
    "~*s-static.ak.facebook.com.edgekey.net"         1;
    "~*sac-h-ct-m-fbx.fbsbx.com.online-metrix.net"   1;
    "~*static.ak.facebook.com.edgesuite.net"         1;
    "~*tfbnw.net"                                    1;
    "~*whatsapp.com"                                 1;
}
# /usr/local/etc/nginx/nginx.conf

include faceblock.conf;

if ($facebook_referer) {
    return 444;
}

At this point, I consider Facebook to be both a criminal enterprise and a megaphone for hate speech. At least in my house I will keep them out.