Re: Conditional Blocks based upon Remote IP Address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx

---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux