Skip to content

Instantly share code, notes, and snippets.

@lukapaunovic
Created October 28, 2025 09:05
Show Gist options
  • Select an option

  • Save lukapaunovic/d8b072ec475e54da62c21204dcb8bbb0 to your computer and use it in GitHub Desktop.

Select an option

Save lukapaunovic/d8b072ec475e54da62c21204dcb8bbb0 to your computer and use it in GitHub Desktop.
Block Facebook Ads Idiotism
Ovo ide u server { } blok sajta:
if ($block_preview_ajax) { return 403; }
location = /wp-admin/admin-ajax.php {
if ($is_preview_bot) { return 403; }
proxy_pass https://79.101.60.115:8443;
}
location = /wp-content/plugins/translatepress-business/add-ons-pro/automatic-language-detection/includes/trp-ald-ajax.php {
if ($is_preview_bot) { return 403; }
proxy_pass https://79.101.60.115:8443;
}
location / {
if ($block_preview_ajax) { return 403; }
proxy_pass https://79.101.60.115:8443;
}
OVo u okviru http { } :
# 1) Prepoznaj preview/crawl UA (dopuni po potrebi)
# ===============================================
# FACEBOOK / META BOT DETEKCIJA (FULL LIST)
# ===============================================
map $http_user_agent $is_preview_bot {
default 0;
# Zvanični Facebook/Meta tokeni
~*facebookexternalhit 1;
~*facebot 1;
~*facebookcatalog 1;
~*facebookplatform 1;
# Meta novi/oglašivački/web-indexer botovi iz logova
~*meta-externalads 1;
~*meta-webindexer 1;
~*meta-externalhit 1; # pokriva Meta-Externalhit / Meta-ExternalHit
~*meta-externalagent 1;
~*meta-externalfetcher 1;
~*meta-crawler 1;
# Fallback (ako se pojavi samo "facebook")
~*facebook 1;
}
# ===============================================
# DETEKCIJA SVIH OPASNIH QUERY PARAMETARA
# (ne koristimo $arg_* jer add-to-cart ima crticu)
# ===============================================
map $args $has_bad_qs {
default 0;
# WC AJAX (sve)
~*(^|&)wc-ajax= 1;
# klasični WooCommerce add/remove
~*(^|&)add-to-cart= 1;
~*(^|&)remove_item= 1;
# FKCart plugin (fkcart_add_item, fkcart_get_slide_cart, sve ostale)
~*(^|&)fkcart_ 1;
# TranslatePress – Automatic Language Detection AJAX
~*(^|&)action=trp_ald_ 1;
}
# ===============================================
# DETEKCIJA ADMIN-AJAX PO PUTANJI
# ===============================================
map $uri $is_admin_ajax {
default 0;
=/wp-admin/admin-ajax.php 1;
}
# ===============================================
# FINALNI "KILL SWITCH" ZA FB/META BOTOVE
# (ako je bot + bilo koja od gore navedenih meta)
# ===============================================
map "$is_preview_bot:$has_bad_qs:$is_admin_ajax" $block_preview_ajax {
default 0;
"1:1:0" 1; # bot + loš QS
"1:0:1" 1; # bot + admin-ajax čak i bez QS
"1:1:1" 1; # bot + oba
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment