0

I cannot setup req_limit_zone for specific file inside location since, as I figured it out, the main location catches the request and it never comes to the targeted file. Configuration inside nginx looks like this

location / {
                try_files $uri $uri/ /index.php?=$uri&$args;
        }

        location /wordpress/ {
                try_files $uri $uri/ /wordpress/index.php?$args;
        }

        location /wordpress/xmlrpc.php$ {
                limit_req zone=mylimit;
        }

The goal is to setup limit_req_zone on xmlrpc.php file so I can create fail2ban rules to ban people who try to send POST requests.

Mat
  • 2,378
  • 3
  • 26
  • 35
  • You have added a `$` to the end of the URI. Even if you fix the typo, the `location` block needs the code from the `location ~ \.php$` block, which was previously used to process the request. – Richard Smith Feb 03 '21 at 12:52
  • @RichardSmith Thank you for your reply i have made changes and i did some other testing i have placed limit configuration inside /wordpress location and it is catching limits now but still it doesnt catch /wordpress/xmlrpc.php but when i try to hit /wordpress/test.txt the limit conf triggers, dont know why it doesnt work for .php files. – aleksandars91 Feb 03 '21 at 14:07

0 Answers0