Apache settings based on client's IP address

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
Mario Aeby [ Di, 02 Oktober 2007 22:13 ] [ ID #1834191 ]

Re: Apache settings based on client's IP address

On Tue, 02 Oct 2007 13:13:53 -0700, Mario Aeby
<emeidi [at] gmail.com> 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)
Kees Nuyt [ Mi, 03 Oktober 2007 10:28 ] [ ID #1834957 ]

Re: Apache settings based on client's IP address

> 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
Mario Aeby [ Do, 04 Oktober 2007 18:36 ] [ ID #1836159 ]

Re: Apache settings based on client's IP address

In article <1191356033.333347.253510 [at] y42g2000hsy.googlegroups.com>,
Mario Aeby <emeidi [at] gmail.com> 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/
patpro [ Do, 04 Oktober 2007 18:53 ] [ ID #1836161 ]

Re: Apache settings based on client's IP address

In article <patpro-631D9D.18533504102007 [at] news-1.proxad.net>,
patpro ~ patrick proniewski <patpro [at] boleskine.patpro.net> wrote:

> In article <1191356033.333347.253510 [at] y42g2000hsy.googlegroups.com>,
> Mario Aeby <emeidi [at] gmail.com> 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/
patpro [ Do, 04 Oktober 2007 18:55 ] [ ID #1836162 ]
Webserver » alt.apache.configuration » Apache settings based on client's IP address

Vorheriges Thema: apachebench (ab) and concurrency (-c)
Nächstes Thema: vhosts outside the default document root