dbContext / SiteShield-OpenResty

Advanced Layer 7 HTTP(s) DDoS Mitigation module for OpenResty ("dynamic web platform based on NGINX and LuaJIT")
GNU General Public License v3.0
25 stars 7 forks source link

support allow_ua #2

Open w796933 opened 3 years ago

w796933 commented 3 years ago

Will consider adding support in the future userAgent whitelist ?

w796933 commented 3 years ago

sir . how to Prohibit search engine reverse detection ? Because the dig command is blocking. Resulting in very low efficiency. Site 500 error.

if (string_find(useragent, "Googlebot") or 
    string_find(useragent, "bingbot") or 
    string_find(useragent, "Yahoo") or 
    string_find(useragent, "DuckDuckBot")) then

    local getHostname = io.popen("dig -x " .. remote_ip .. " +short")
    local resolvedHostname = getHostname:read("*a")
    getHostname:close()

    local getIP = io.popen("getent hosts " .. resolvedHostname)
    local resolvedIP = getIP:read("*a")
    getIP:close()

    if (string_find(resolvedHostname, "google.com") or 
        string_find(resolvedHostname, "googlebot.com") or 
        string_find(resolvedHostname, "search.msn.com") or 
        string_find(resolvedHostname, "crawl.yahoo.net") or 
        string_find(resolvedHostname, "duckduckbot.duckduckgo.com")) then