C0nw0nk / Nginx-Lua-Anti-DDoS

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

WAF filters always ends-up in default error 500 Page

venomone opened this issue · comments

Hello,

first of all thanks for your nice work, I really like this "tiny" script ;)
Anyways I'm facing an issue I was not able to figure out myself.
I'm running this script on top of my Django application, problem now is that everytime a WAF filtered path/file applies or in other words gets blocked, openresty just returns the default error 500 page instead of my applications custom error page.
At my log i just see: 2020/07/25 21:32:19 [error] 69#69: *25 rewrite or internal redirection cycle while internally redirecting to "/403.html", client: 192.168.240.5, server: localhost, request: "GET /wsgi.py HTTP/1.1", host: "localhost"

nginx.conf (shorted):

...
http {
     upstream backend {
        server 127.0.0.1:8000 max_fails=3 fail_timeout=60s;
     }
...
 server {
        listen 80;
        access_by_lua_file ddos_challenge.lua;
        aio threads=default;
...
location @proxy_to_app {
            proxy_pass http://backend;
            aio threads;
            proxy_read_timeout     100s;
            proxy_connect_timeout  100s;
            proxy_http_version 1.1;
            proxy_redirect off;
            proxy_buffers 16 4k;
            proxy_buffer_size 2k;
            proxy_intercept_errors on;
            proxy_set_header Host $host;
            uwsgi_intercept_errors on;
            gzip on;
            gzip_min_length 1024;
            gzip_comp_level 3;
            gzip_vary on;
            gzip_disable msie6;
            gzip_proxied expired no-cache no-store private auth;
            gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml application/atom+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
            }

location / {
            try_files $uri @proxy_to_app;
            }
...
error_page 412 414 416 444 495 496 497 500 501 502 504 507 /custom_error.html;
        location = /custom_error.html {
            root /app/templates/;
            internal;
        }

Any Idea how I get my custom_error.html displayed if the WAF gets a hit?

Greetz

Okay i found a solution, simply read this: https://groups.google.com/g/openresty-en/c/1XASYFeP61o?pli=1