Apache settings based on client"s IP address
Apache settings based on client"s IP address
am 02.10.2007 22:13:53 von Mario Aeby
Hi there
- --
OS: Linux ALPHA 2.6.21-2-686 #1 SMP Wed Jul 11 03:53:02 UTC 2007 i686
GNU/Linux
Apache: Apache/2.2.4 (Debian) DAV/2 PHP/5.2.3-1+b1
- --
I'd like to have Apache settings enabled/disabled based on the
client's IP address. If a request is made from inside the LAN, I'd
like to have the following setting enabled:
php_value error_reporting 6143
If the request is coming from the WAN, I don't want to disclose any
errors at all, therefore using the default setting in php.ini.
Is there a simple way to accomply this?
I've already looked into Environment Variables [1] but they don't seem
to be aimed at such purposes.
[1] http://httpd.apache.org/docs/2.2/env.html
Best regards
Mario
Re: Apache settings based on client"s IP address
am 03.10.2007 10:28:34 von Kees Nuyt
On Tue, 02 Oct 2007 13:13:53 -0700, Mario Aeby
wrote:
>Hi there
>- --
>OS: Linux ALPHA 2.6.21-2-686 #1 SMP Wed Jul 11 03:53:02 UTC 2007 i686
>GNU/Linux
>Apache: Apache/2.2.4 (Debian) DAV/2 PHP/5.2.3-1+b1
>- --
>
>I'd like to have Apache settings enabled/disabled based on the
>client's IP address. If a request is made from inside the LAN, I'd
>like to have the following setting enabled:
>
>php_value error_reporting 6143
>
>If the request is coming from the WAN, I don't want to disclose any
>errors at all, therefore using the default setting in php.ini.
>
>Is there a simple way to accomply this?
>
>I've already looked into Environment Variables [1] but they don't seem
>to be aimed at such purposes.
>
>[1] http://httpd.apache.org/docs/2.2/env.html
>
>Best regards
>Mario
The Apache and PHP config files are only read during startup, so
you can't do it from there.
Try to put this in the common header include file of your
application (assuming your LAN adresses all start with
192.168.):
if (substr ($_REQUEST['REMOTE_ADDR'],0,8) == '192.168.'){
error_reporting(E_ALL);
} else {
error_reporting(0);
}
I hope this helps.
--
( Kees
)
c[_] I went to a planet where the dominant lifeform had no
bilateral symmetry, and all I got was this stupid F-Shirt. (#108)
Re: Apache settings based on client"s IP address
am 04.10.2007 18:36:17 von Mario Aeby
> Try to put this in the common header include file of your
> application (assuming your LAN adresses all start with
> 192.168.):
I think this should be possible without inserting this snippet into
every PHP script on my server :-/
Thanks anyway for your suggestion!
Mario
Re: Apache settings based on client"s IP address
am 04.10.2007 18:53:36 von patpro
In article <1191356033.333347.253510@y42g2000hsy.googlegroups.com>,
Mario Aeby wrote:
> I'd like to have Apache settings enabled/disabled based on the
> client's IP address. If a request is made from inside the LAN, I'd
> like to have the following setting enabled:
>
> php_value error_reporting 6143
>
> If the request is coming from the WAN, I don't want to disclose any
> errors at all, therefore using the default setting in php.ini.
>
> Is there a simple way to accomply this?
run one virtual host on the WAN IP, and another virtual host on the LAN
IP.
Both vhost should have the same settings, except for the setting
"php_value error_reporting 6143 " that you must add to the LAN vhost.
patpro
--
http://www.patpro.net/
Re: Apache settings based on client"s IP address
am 04.10.2007 18:55:18 von patpro
In article ,
patpro ~ patrick proniewski wrote:
> In article <1191356033.333347.253510@y42g2000hsy.googlegroups.com>,
> Mario Aeby wrote:
>
> > I'd like to have Apache settings enabled/disabled based on the
> > client's IP address. If a request is made from inside the LAN, I'd
> > like to have the following setting enabled:
> >
> > php_value error_reporting 6143
> >
> > If the request is coming from the WAN, I don't want to disclose any
> > errors at all, therefore using the default setting in php.ini.
> >
> > Is there a simple way to accomply this?
>
> run one virtual host on the WAN IP, and another virtual host on the LAN
> IP.
> Both vhost should have the same settings, except for the setting
> "php_value error_reporting 6143 " that you must add to the LAN vhost.
and I forgot: of course, your DNS must be set accordingly. It must
returns LAN address when querying from the LAN, and WAN address when
querying from outside the LAN.
patpro
--
http://www.patpro.net/