You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Tonu Mikk <tm...@umn.edu> on 2007/10/30 17:29:23 UTC

[users@httpd] creating a custom error while restricting access

Hello,

I have set up two virtual hosts in my Apache 2.0 httpd.conf file running 
on Windows XP.  I am restricting which IP addresses can access the pages 
like so:
<Directory      C:/somefolder/*>
                # Restricting by IP access
                AllowOverride None
                Options None
                Order deny,allow
                Deny from all
                Allow from domain.maindomain
                Allow from xxx.xxx
                Allow from localhost
        </Directory>
When people are not in the allowed subnet range, they get a Forbidden 
(Error 403) message.  I would like to modify this message. 

I read that I could accomplish this by creating a htaccess file in 
htdocs and put an entry into that file that points to the custom error 
page.  My htaccess file now looks like this:
Error 403 Forbidden 403error.html
However, I still get the default error page.  I am not able to access 
the 403error.html directly either.  This is probably because, htdocs is 
no longer home directory for serving pages.  I tried placing the 
htaccess and 403.html file into c:\somefolder ,but that did not produce 
the custom error message either.

How should I create the custom error message when using virtual hosts 
and restricting access to the folder?

Thank you,

Tonu


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


Re: [users@httpd] creating a custom error while restricting access

Posted by Joshua Slive <jo...@slive.ca>.
On 10/30/07, Tonu Mikk <tm...@umn.edu> wrote:
> I think I am starting to get it now.  I tried the following in my
> virtual host portion:
>
> Alias /errors c:/errors
> <Directory c:/errors>
> Order allow,deny
> Allow from all
> </Directory>
> ErrorDocument 403 /errors/403.html ,
>
> But it produces the following page:
>
>
>   Forbidden
>
> You don't have permission to access /errors/403.htm on this server.
> Additionally, a 403 Forbidden error was encountered while trying to use
> an ErrorDocument to handle the request.
>
> In the error.log I find:
> client denied by server configuration: C:/somefolder/html/dummy.py
>
> I wonder if the Alias portion doesn't work because of these two lines in
> my virtual host file:
>
>         AliasMatch ^/@@file(.*) C:/somefolder/html$1
>         AliasMatch ^/(?!@@file)(.*) C:/somefolder/html/dummy.py/$1
>
> What else should I try?

Uhhh... Yeah. Those lines are catching every request to your server.
You may be able to fix this by listing your errors Alias FIRST in the
config, before those other Aliases. Otherwise, you can used
RewriteRule, which allows for explicit ordering.

Joshua.

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


Re: [users@httpd] creating a custom error while restricting access

Posted by Tonu Mikk <tm...@umn.edu>.
I think I am starting to get it now.  I tried the following in my 
virtual host portion:

Alias /errors c:/errors
<Directory c:/errors>
Order allow,deny
Allow from all
</Directory>
ErrorDocument 403 /errors/403.html ,

But it produces the following page:


  Forbidden

You don't have permission to access /errors/403.htm on this server.
Additionally, a 403 Forbidden error was encountered while trying to use 
an ErrorDocument to handle the request.

In the error.log I find:
client denied by server configuration: C:/somefolder/html/dummy.py

I wonder if the Alias portion doesn't work because of these two lines in 
my virtual host file:

        AliasMatch ^/@@file(.*) C:/somefolder/html$1
        AliasMatch ^/(?!@@file)(.*) C:/somefolder/html/dummy.py/$1

What else should I try?

Thanks,
Tonu

Joshua Slive wrote:
> On 10/30/07, Tonu Mikk <tm...@umn.edu> wrote:
>   
>> Joshua,  thanks for the tip!  I tried the following in my httpd.conf
>> virtual host portion:
>>
>>          Alias /errors C:/somefolder/errors
>>         <Directory C:/somefolder/errors>
>>         Order allow,deny
>>         Allow from all
>>         </Directory>
>>     ErrorDocument 403 http://domain.maindomain/errors/403.html,
>> But I get "The Page Isn't Redirecting Properly" error.  I also cannot go
>> to the URL of http://domain.maindomain/errors/403.html file directly.  I
>> wonder if this is because I am restricting the top level directory
>> (C:/somefolder) to certain IP addresses and then I am trying to access
>> the subfolder (C:/somefolder/errors) to all.  Can I restrict the top
>> level directory, and still allow full access to a subdirectory?
>>     
>
> Yes, but it is much simpler to just Alias /errors to someplace that is
> not restricted, as I showed you in my example. (There is no need to
> even use Alias if you are going to put the directory back underneath
> an already-accessible directory. Don't do that. Use Alias to put the
> directory someplace clean.)
>
> Also, as I showed in my example, don't use a full URL in
> ErrorDocument. Use a URL-path, containing just the part after the
> hostname.
>
> Finally, always check the error log when you are having problems.
>
> Joshua.
>
> ---------------------------------------------------------------------
> 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


Re: [users@httpd] creating a custom error while restricting access

Posted by Joshua Slive <jo...@slive.ca>.
On 10/30/07, Tonu Mikk <tm...@umn.edu> wrote:
> Joshua,  thanks for the tip!  I tried the following in my httpd.conf
> virtual host portion:
>
>          Alias /errors C:/somefolder/errors
>         <Directory C:/somefolder/errors>
>         Order allow,deny
>         Allow from all
>         </Directory>
>     ErrorDocument 403 http://domain.maindomain/errors/403.html,
> But I get "The Page Isn't Redirecting Properly" error.  I also cannot go
> to the URL of http://domain.maindomain/errors/403.html file directly.  I
> wonder if this is because I am restricting the top level directory
> (C:/somefolder) to certain IP addresses and then I am trying to access
> the subfolder (C:/somefolder/errors) to all.  Can I restrict the top
> level directory, and still allow full access to a subdirectory?

Yes, but it is much simpler to just Alias /errors to someplace that is
not restricted, as I showed you in my example. (There is no need to
even use Alias if you are going to put the directory back underneath
an already-accessible directory. Don't do that. Use Alias to put the
directory someplace clean.)

Also, as I showed in my example, don't use a full URL in
ErrorDocument. Use a URL-path, containing just the part after the
hostname.

Finally, always check the error log when you are having problems.

Joshua.

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


Re: [users@httpd] creating a custom error while restricting access

Posted by Tonu Mikk <tm...@umn.edu>.
Joshua,  thanks for the tip!  I tried the following in my httpd.conf 
virtual host portion:

         Alias /errors C:/somefolder/errors
        <Directory C:/somefolder/errors>
        Order allow,deny
        Allow from all
        </Directory>
    ErrorDocument 403 http://domain.maindomain/errors/403.html,
But I get "The Page Isn't Redirecting Properly" error.  I also cannot go 
to the URL of http://domain.maindomain/errors/403.html file directly.  I 
wonder if this is because I am restricting the top level directory 
(C:/somefolder) to certain IP addresses and then I am trying to access 
the subfolder (C:/somefolder/errors) to all.  Can I restrict the top 
level directory, and still allow full access to a subdirectory?

Thank you,

Tonu

Joshua Slive wrote:
> On 10/30/07, Tonu Mikk <tm...@umn.edu> wrote:
>   
>> Hello,
>>
>> I have set up two virtual hosts in my Apache 2.0 httpd.conf file running
>> on Windows XP.  I am restricting which IP addresses can access the pages
>> like so:
>> <Directory      C:/somefolder/*>
>>                 # Restricting by IP access
>>                 AllowOverride None
>>                 Options None
>>                 Order deny,allow
>>                 Deny from all
>>                 Allow from domain.maindomain
>>                 Allow from xxx.xxx
>>                 Allow from localhost
>>         </Directory>
>> When people are not in the allowed subnet range, they get a Forbidden
>> (Error 403) message.  I would like to modify this message.
>>
>> I read that I could accomplish this by creating a htaccess file in
>>     
>
> Forget about .htaccess. In httpd.conf, put
> Alias /errors c:/unrestricted/path/to/errors
> <Directory c:/unrestricted/path/to/errors>
> Order allow,deny
> Allow form all
> </Directory>
> ErrorDocument 403 /errors/403.html
>
> Joshua.
>
> ---------------------------------------------------------------------
> 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


Re: [users@httpd] creating a custom error while restricting access

Posted by Joshua Slive <jo...@slive.ca>.
On 10/30/07, Tonu Mikk <tm...@umn.edu> wrote:
> Hello,
>
> I have set up two virtual hosts in my Apache 2.0 httpd.conf file running
> on Windows XP.  I am restricting which IP addresses can access the pages
> like so:
> <Directory      C:/somefolder/*>
>                 # Restricting by IP access
>                 AllowOverride None
>                 Options None
>                 Order deny,allow
>                 Deny from all
>                 Allow from domain.maindomain
>                 Allow from xxx.xxx
>                 Allow from localhost
>         </Directory>
> When people are not in the allowed subnet range, they get a Forbidden
> (Error 403) message.  I would like to modify this message.
>
> I read that I could accomplish this by creating a htaccess file in

Forget about .htaccess. In httpd.conf, put
Alias /errors c:/unrestricted/path/to/errors
<Directory c:/unrestricted/path/to/errors>
Order allow,deny
Allow form all
</Directory>
ErrorDocument 403 /errors/403.html

Joshua.

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