Is there a way in apache to limit the amount of users that can view a site in a certain month? I'd need to do this for individual vhosts.
Something along the lines of:
<VirtualHost *:80>
ServerName website.com
DocumentRoot "/var/www/website.com/public"
**MONTHLY_USER_LIMIT** = 5000
</VirtualHost>
Is there anything in Apache that does this (or nginx) ?
Thanks!
No, but you could configure the access log to go to a program that does the counting and then turns off a site. You'd have to make it resilient to apache restarts.
This is quite trivial if you're using something like PHP with Apache. You could implement the count manually on a per user basis using cookies (optimally), or if they have cookies disabled use something clever. This type of stuff belongs in a PHP script.
It seems that with a setup like yours, you probably have a user/password hash for authentication, so when they log in, log it. Every time they start a new session, log it. If they reach 5000 sessions, return a 401 error or something explaining that they have exceeded their per-month allotment of views.
If this truly is on a per-user basis, a server-side script would make the most sense. You don't even need to have a database, a simple text file will do the trick.
I'm pretty sure that a PHP script can access what host it is being accessed on (just look at the URL).