Skip to content

A simple system to rate-limit site visitors by time interval/request amount.

Notifications You must be signed in to change notification settings

a3r0id/php-rate-limiting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 

Repository files navigation

php-rate-limiting

A simple system to rate-limit site visitors by time interval/request amount.

This is NOT a good solution for production use! For a more secure and scalable solution, refer to something like nikolaposa/rate-limit.

Adjust specifications via config.json (aka rate-limiting.conf).


Usage:

[1] Edit your configuration:

Notes:
If "die_on_rate_limit" is false then visitor will be redirected to the "redirect_location" when limited.
"request_allowance" should always be (amount to allow + 1) as in regards to the example config, it will limit the visitor on their 25th request, NOT THE 26th!

[
    {
        "database_file_name": "/usr/share/requests.json",
        "interval_time_seconds": 300,
        "request_allowance": 25,
        "redirect_location": "https://google.com",
        "die_on_rate_limit": false 
    }
]

[2] - Include in your project

<?php
require "rate-limiting.php";// Process request
echo "hello world!";// If not limited, serve the rest of the file.
?>

About

A simple system to rate-limit site visitors by time interval/request amount.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published