Chris,

Could you use a CGI frontend for doing your limiting? Basically a script or
program that runs your custom logic then either executes the CGI or returns
an error status? To use mod_wsgi, you would need to write a Python web
application that would perform said logic, then graft the CGI program into
it using some sort of CGI bridge (write WSGI headers and input to CGI
application via subprocess module, then read headers and output back to
WSGI). There are a lot of CGI utilities in the cgi module that may help in
doing this, but it seems more complicated than a CGI frontend.

http://docs.python.org/2/library/cgi.html

In fact, you could write the wrapper script in Python, using cgi module
would help here. The difference being that you would still invoke this
Python script as a CGI rather than via mod_wsgi.




On Thu, Jul 11, 2013 at 1:55 PM, Chris Chen <[email protected]> wrote:

> Jason and Graham,
>
> Yes, I have looked at those modules but didn't think they would work for
> my situation.   More details on the rate limiting logic, please note the
> client is a configurable program
>
> 1) Counting
>     Instead of tracking http request, we track transactions which are
> consisted of a group of http requests.  This requires custom logic to group
> requests.
>
> 2) Blocking
>     We cannot immediately block requests once the transaction threshold is
> exceeded because the request could be part of a transaction and they will
> be allowed to complete.  Blocking will only be done on the very first http
> request of a transaction.
>
> Thanks.
>
>
> On Thursday, July 11, 2013 10:38:34 AM UTC-7, Graham Dumpleton wrote:
>
>> And here I was thinking that was only being added in Apache 2.5 so I
>> didn't mention it. My Google Fu failed me.
>>
>> But then, still needs Apache 2.4, which Linux distros tend not to ship
>> with.
>>
>> Graham
>>
>> On 11/07/2013, at 10:33 AM, Jason Garber <[email protected]> wrote:
>>
>> Have you looked at this:
>> http://httpd.apache.org/docs/**2.4/mod/mod_ratelimit.html<http://httpd.apache.org/docs/2.4/mod/mod_ratelimit.html>
>>
>> Just checking...
>>
>>
>> On Thu, Jul 11, 2013 at 1:23 PM, Chris Chen <[email protected]> wrote:
>>
>>> Hey Jason,
>>>
>>> We would like to add custom logic to rate limiting certain types of
>>> request by IP.  Basically,  if an IP had made certain requests too many
>>> times within last x mins or seconds, we will return an error, Otherwise, we
>>> will let the cgi handles the request.
>>>
>>> Thanks.
>>>
>>>
>>> On Thursday, July 11, 2013 9:37:07 AM UTC-7, Jason Garber wrote:
>>>
>>>> Hi Chris,
>>>>
>>>> Can you expand on what type of "custom logic" you are referring to?  I
>>>> assume said CGI script returns HTML?  Is that what you wish to manipulate
>>>> via mod_wsgi+python?
>>>>
>>>> J
>>>>
>>>>
>>>>
>>>> On Thu, Jul 11, 2013 at 12:24 PM, Chris Chen <[email protected]> wrote:
>>>>
>>>>> Hi there.
>>>>>
>>>>> We use a CGI script that is written in C (not written by us), compiled
>>>>> and directly called from apache.  We would like to add some custom logic 
>>>>> on
>>>>> top of it, and we are hoping we can wrap it with mod_wsgi.
>>>>>
>>>>> Is this a good idea? Does anyone have an example?
>>>>>
>>>>> Thanks!
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "modwsgi" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to modwsgi+u...@**googlegroups.com.
>>>>> To post to this group, send email to [email protected].
>>>>>
>>>>> Visit this group at 
>>>>> http://groups.google.com/**group**/modwsgi<http://groups.google.com/group/modwsgi>
>>>>> .
>>>>> For more options, visit 
>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out>
>>>>> .
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "modwsgi" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to modwsgi+u...@**googlegroups.com.
>>> To post to this group, send email to [email protected].
>>> Visit this group at 
>>> http://groups.google.com/**group/modwsgi<http://groups.google.com/group/modwsgi>
>>> .
>>> For more options, visit 
>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>>> .
>>>
>>>
>>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "modwsgi" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to modwsgi+u...@**googlegroups.com.
>> To post to this group, send email to [email protected].
>> Visit this group at 
>> http://groups.google.com/**group/modwsgi<http://groups.google.com/group/modwsgi>
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>> .
>>
>>
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "modwsgi" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/modwsgi.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/modwsgi.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to