A Lua-based Anti-DDoS script for Nginx that uses a JavaScript authentication puzzle inspired by Cloudflare's 'I am under attack' mode to protect web servers from all types of Layer 7 attacks.
A Anti-DDoS script to protect Nginx web servers using Lua with a HTML Javascript based authentication puzzle inspired by Cloudflare I am under attack mode an Anti-DDoS authentication page protect yourself from every attack type All Layer 7 Attacks Mitigating Historic Attacks DoS DoS Implications DDoS All Brute Force Attacks Zero day exploits Social Engineering Rainbow Tables Password Cracking Tools Password Lists Dictionary Attacks Time Delay Any Hosting Provider Any CMS or Custom Website Unlimited Attempt Frequency Search Attacks HTTP Basic Authentication HTTP Digest Authentication HTML Form Based Authentication Mask Attacks Rule-Based Search Attacks Combinator Attacks Botnet Attacks Unauthorized IPs IP Whitelisting Bruter THC Hydra John the Ripper Brutus Ophcrack unauthorized logins Injection Broken Authentication and Session Management Sensitive Data Exposure XML External Entities (XXE) Broken Access Control Security Misconfiguration Cross-Site Scripting (XSS) Insecure Deserialization Using Components with Known Vulnerabilities Insufficient Logging & Monitoring Drupal WordPress Joomla Flash Magento PHP Plone WHMCS Atlassian Products malicious traffic Adult video script avs KVS Kernel Video Sharing Clip Bucket Tube sites Content Management Systems Social networks scripts backends proxy proxies PHP Python Porn sites xxx adult gaming networks servers sites forums vbulletin phpbb mybb smf simple machines forum xenforo web hosting video streaming buffering ldap upstream downstream download upload rtmp vod video over dl hls dash hds mss livestream drm mp4 mp3 swf css js html php python sex m3u zip rar archive compressed mitigation code source sourcecode chan 4chan 4chan.org 8chan.net 8ch 8ch.net infinite chan 8kun 8kun.net anonymous anon tor services .onion torproject.org nginx.org nginx.com openresty.org darknet dark net deepweb deep web darkweb dark web mirror vpn reddit reddit.com adobe flash hackthissite.org dreamhack hack hacked hacking hacker hackers hackerz hackz hacks code coding script scripting scripter source leaks leaked leaking cve vulnerability great firewall china america japan russia .gov government http1 http2 http3 quic q3 litespeedtech litespeed apache torrents torrent torrenting webtorrent bittorrent bitorrent bit-torrent cyberlocker cyberlockers cyber locker cyberbunker warez keygen key generator free irc internet relay chat peer-to-peer p2p cryptocurrency crypto bitcoin miner browser xmr monero coinhive coin hive coin-hive litecoin ethereum cpu cycles popads pop-ads advert advertisement networks banner ads protect ovh blazingfast.io amazon steampowered valve store.steampowered.com steamcommunity thepiratebay lulzsec antisec xhamster pornhub porn.com pornhub.com xhamster.com xvideos xvdideos.com xnxx xnxx.com popads popcash cpm ppc
This tool is designed for web administrators and security professionals who want to protect Nginx web servers from DDoS attacks, brute force attempts, and various web exploits by challenging visitors with an authentication puzzle. It is particularly useful during active attacks to filter legitimate human traffic from malicious bots or automated attacks, ensuring uptime and service availability.
It is recommended to use this tool with the latest Nginx builds that support Lua to avoid compatibility issues. Proper tuning of IP/User-Agent whitelists and blacklists is essential to minimize false positives. Logging can be integrated with Fail2Ban for automated banning of malicious IPs. The tool is optimized for Layer 7 attacks and works with both HTTP and HTTPS traffic.
Clone the repository from https://github.com/C0nw0nk/Nginx-Lua-Anti-DDoS
Ensure you have the latest Nginx build with Lua module support (e.g., OpenResty or Nginx+Lua)
Edit the configuration file `lua/anti_ddos_challenge.lua` to customize settings for your environment
Integrate the Lua script into your Nginx configuration to enable the Anti-DDoS challenge
Reload or restart Nginx to apply the changes
Monitor logs for authentication puzzle success/failure to tune rules or integrate with Fail2Ban
Edit `lua/anti_ddos_challenge.lua`
Customize Anti-DDoS settings such as whitelists, blacklists, and authentication parameters.
Integrate Lua script into Nginx config
Add Lua directives in your Nginx configuration to enable the Anti-DDoS challenge page and filtering.
Reload Nginx
Apply configuration changes after editing Lua script or Nginx config.