httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeroen van Meeuwen" <kana...@pczone-clan.nl>
Subject RE: [users@httpd] Custom authorization of static content
Date Tue, 24 Aug 2004 12:39:42 GMT
Here's an example:

My httpd.conf sais:

<VirtualHost *:80>
    ServerAdmin webmaster@pczone-clan.nl
    DocumentRoot /home/kanarip/public_html/
    Alias /data /data/
    ServerName www.apache.lan
</VirtualHost>

<Directory "/data/">
    Order Allow,Deny
    Allow from All
     <IfModule mod_php5.c>
         php_value auto_prepend_file "/home/kanarip/public_html/auth.php"
     </IfModule>
</Directory>

The contents of auth.php:

<?php
	if ( $_SERVER["REMOTE_ADDR"] == '131.211.232.203' ) continue;
	else
	{
		header("Status: 403 Unauthorized");
		die;
	}
?>

This works excellent on httpd-2.0.50 with PHP 5.0.0

Let me know if it works for you :)

Kind regards,

kanarip

> -----Original Message-----
> From: Robert Andersson [mailto:robert@profundis.nu] 
> Sent: dinsdag 24 augustus 2004 14:23
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] Custom authorization of static content
> 
> Jeroen van Meeuwen wrote:
> > Anyway, I think I have a solution:
> >
> > From within you VirtualHost or Directory directive, you might
> > specify:
> >
> > <IfModule mod_php5.c>
> > php_value auto_prepend_file
> > "/some/directory/to/your/I-really-need-this-authentication.php"
> > </IfModule>
> >
> > This file is parsed and executed, and so might check 
> weither a user is 
> > authenticated.
> 
> Hmm... from what I gather from the docs, it is only parsed 
> and executed when a document affected by the directive is 
> parsed by PHP. I could be wrong, though.
> 
> As stated, the problem is mainly static contents (images, 
> PDF-files etc) that I wish to keep static, yet have custom 
> code executed in the authorization stage of the request. In 
> such way, that if the custom code "returned" 403, my standard 
> 403 error document would be served.
> 
> Regards,
> Robert Andersson
> 
> 
> ---------------------------------------------------------------------
> 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
> 


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