newPerlr has asked for the wisdom of the Perl Monks concerning the following question:

I'm new to perl and this is the first time I'm working with mod_perl and I'm seeking perl monks wisdom please help me.


This is what I need to do.

I have a Apache 2.2 server which takes HTTP input requests and redirects them to multiple virtual server using proxy mainly this is used as a load-balance.

What i need to do is when a request comes and before it is forwarded I need to read the request and if the request does not meet the requirement (spam, format mismatch) I need to stop it from being forwarded. Can this be done?? and how can it be done?

Thank you in advance.

Replies are listed 'Best First'.
Re: mod_perl HTTP input request
by CountZero (Bishop) on Oct 20, 2009 at 06:16 UTC
    Welcome to Perl! You are at the start of a fascinating journey, which will have its ups and downs, but will never be without interest.

    As to your question: the answer is "YES". mod_perl allows you to have access to each of Apache's HTTP Request Cycle Phases by writing a specific PerlResponseHandler. I'm not saying it will be trivially easy to do so as Apache is a complicated piece of software, but at least mod_perl makes difficult things possible.

    Thoroughly read the mod_perl documentation and check the wealth of Apache modules at CPAN. It is unlikely you will find one module which exactly solves all your problems in one go, but at least you can take some inspiration from their code and brew your own.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James