httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Foertsch <torsten.foert...@gmx.net>
Subject Re: [users@httpd] Conditional Blocks based upon Remote IP Address
Date Tue, 21 Oct 2008 15:16:01 GMT
On Tue 21 Oct 2008, Clint Priest wrote:
> When the php module is installed into apache there is a php_flag and
> php_value directive available which could be used to set the value
> from within Apache, the only trick is to only have them take effect
> for certain remote ips.  They would be:
>
> php_flag display_errors On
> php_flag display_startup_errors On

Provided these directives are allowed in a Directory block or .htaccess 
file you can do that if you have modperl installed:

<Perl>
package My::Fixup;
use strict;
use warnings;
use Apache2::RequestRec ();
use Apache2::Connection ();
use Apache2::Const -compile=>'OK';

sub handler {
  my $r=shift;
  if( $r->connection->remote_ip =~ /192\.168\.0\.\d+/ ) {
    $r->add_config(['php_flag display_errors On',
                    'php_flag display_startup_errors On'],
                   ~0);
  }
  return Apache2::Const::OK;
}
</Perl>
PerlFixupHandler My::Fixup

The string between the 2 slashes in the line with "->remote_ip" is a 
regular expression that matches your ip addresses.

See also http://perl.apache.org/docs/2.0/api/Apache2/Connection.html and 
http://perl.apache.org/docs/2.0/api/Apache2/RequestRec.html

Torsten

--
Need professional mod_perl support?
Just hire me: torsten.foertsch@gmx.net

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message