LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-19-2011, 04:41 PM   #1
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Rep: Reputation: 15
Unhappy Apache2 403 Error Document


I have a problem where people can't view the 403 error document(that is also denied access to). Yet people on my allow list CAN view it when navigating to the root directory (which I want blocked).

So 172.25.0.150 >> http://172.25.0.165/website = success
So 172.25.0.150 >> http://172.25.0.165/ = 403 document page (success)
So 172.25.1.15 >> http://172.25.0.165/website = Denied, but no 403 page
So 172.25.1.15 >> http://172.25.0.165/ = Denied, but no 403 error page(my one)

Any help would be appreciated

<VirtualHost *:80>

ServerAdmin blahblah@blah.net
ServerName 172.25.0.165
DocumentRoot /var/www/
ServerSignature Off
HostNameLookups Off
ErrorLog /var/www/logs/error.log
<Directory />
Options None
AllowOverride None
Deny from All
</Directory>
<Directory /var/www/website>
Options Indexes FollowSymLinks MultiViews IncludesNoExec
Order deny,allow
Deny from all
Allow from 172.25.0.219
Allow from 172.25.0.218
Allow from 172.25.0.157
Allow from 172.25.0.150
Allow from 172.25.0.130
Allow from 172.25.0.165

</Directory>
<Directory /var/www/error/>
Allow from all
</Directory>
#Set Directory Index
<IfModule dir_module>
DirectoryIndex index.html index.php index.php4 index.cgi index.pl
</ifmodule>
#Error documents here
ErrorDocument 403 /error/403.html
</VirtualHost>
 
Old 12-19-2011, 06:51 PM   #2
novice06
Member
 
Registered: Mar 2006
Location: Singapore
Distribution: RHEL, CentOS
Posts: 132

Rep: Reputation: 23
"allow from" is answer
You can add another line
Allow from 172.25.1.x
x replace with your client ip. You can even allow whole network range
 
Old 12-20-2011, 12:14 PM   #3
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Original Poster
Rep: Reputation: 15
Ah I was hoping that wasn't the case :s
So my deny from "everything else" has blocked access to the 403 error document that I've created?

I guess I'd have to append another module to say that:

"If incoming address is not on allow list, show 403 error document (403.html)" ?


Thanks for the input
 
Old 12-20-2011, 12:18 PM   #4
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Original Poster
Rep: Reputation: 15
Ok: Update.

The computer that I'm testing from (has an ipaddress not on the allow list) can view the 403 error document when I type in the direct path:

172.25.0.165/error/403.html

But it cannot view the 403 error document if I navigate to the root directory(which is blocked), (Or any other blocked directory for that matter)
If a client on the allow list navigates to the root directory, it gets the correct error page :s
 
Old 12-20-2011, 03:59 PM   #5
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Hi

Your configuration is correct, so it should work. Take a look at error_log to see if you find anything.
In the meantime you can use:
Code:
ErrorDocument 403 http://172.25.0.165/error/403.html
Regards
 
1 members found this post helpful.
Old 12-21-2011, 12:25 PM   #6
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Original Poster
Rep: Reputation: 15
[Thu Dec 22 07:24:03 2011] [error] [client 172.25.1.1] client denied by server configuration: /var/www/
[Thu Dec 22 07:24:08 2011] [error] [client 172.25.1.1] client denied by server configuration: /var/www/website
[Thu Dec 22 07:25:02 2011] [error] [client 172.25.1.1] Directory index forbidden by Options directive: /var/www/error/
[Thu Dec 22 07:25:14 2011] [error] [client 172.25.1.1] client denied by server configuration: /var/www/website/wp-admin

It seems to be denied by the configuration file. However I'm still not seeing why. My error document is allowed, so it should be re-directed :s

I'll give the http direct link method a go and see how that works
 
Old 12-21-2011, 12:28 PM   #7
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Original Poster
Rep: Reputation: 15
Ok, the direct HTTP method works. However it's only an interm solution as I don't really want the link to be displayed like that.

I shouldn't have to use .htaccess files surely? having only two directories should mean the main config file should be sufficient?
 
Old 12-21-2011, 01:23 PM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Quote:
[Thu Dec 22 07:24:03 2011] [error] [client 172.25.1.1] client denied by server configuration: /var/www/
[Thu Dec 22 07:24:08 2011] [error] [client 172.25.1.1] client denied by server configuration: /var/www/website
[Thu Dec 22 07:25:02 2011] [error] [client 172.25.1.1] Directory index forbidden by Options directive: /var/www/error/
[Thu Dec 22 07:25:14 2011] [error] [client 172.25.1.1] client denied by server configuration: /var/www/website/wp-admin

It seems to be denied by the configuration file. However I'm still not seeing why. My error document is allowed, so it should be re-directed :s
Huh. Between the first 2 logs (access to forbidden pages) and the 3rd (access to /error, meaning apache tried to give the 403 error document), there is a 1 min. gap. How comes?
Are you by any chance using mod_rewrite or something? As I see you're using wordpress, that comes with some mod_rewrite rules, so it's worth looking into them if you're not using your own.
Regarding the "Directory index forbidden by Options directive: /var/www/error/", add an index.html so apache stops complaining


Quote:
Ok, the direct HTTP method works. However it's only an interm solution as I don't really want the link to be displayed like that.
As I told you you can use it while trying to solve your problem. And since it works as expected, it makes me think that it is mod_rewrite that is responsible for this behavior
 
1 members found this post helpful.
Old 12-21-2011, 02:03 PM   #9
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bathory View Post
Huh. Between the first 2 logs (access to forbidden pages) and the 3rd (access to /error, meaning apache tried to give the 403 error document), there is a 1 min. gap. How comes?
Are you by any chance using mod_rewrite or something? As I see you're using wordpress, that comes with some mod_rewrite rules, so it's worth looking into them if you're not using your own.
Regarding the "Directory index forbidden by Options directive: /var/www/error/", add an index.html so apache stops complaining
Ah, I was busy between to RDP sessions, so I had a minute between retry attempts on the test VM.

Add an index? So I would add the ifmodule for the <Directory /var/www/error> group?

As for wordpress, I'm not adding any .htaccess files or other virtualhosts for it. It worked fine with the default Apache2 config file too, however I made this one so I could restrict access to other directories.

Quote:
Originally Posted by bathory View Post
As I told you you can use it while trying to solve your problem. And since it works as expected, it makes me think that it is mod_rewrite that is responsible for this behavior
The mod_rewrite does make sense... any idea where I should be looking to find it?
 
Old 12-21-2011, 02:18 PM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Quote:
Ah, I was busy between to RDP sessions, so I had a minute between retry attempts on the test VM.
No, what I'm trying to tell you, is that you should get a 403 error 2 times at the same moment. One for the /website and the other for the /error/403.html (the latter shouldn't happen and it's the problem you're facing, if I understand well your 1st post). You don't get the 2nd error, so apache looks that it works as expected, and gives you the 403 error page!!!
I've tried to do the same setup here (using different docroot), so you should get the following if there was a problem with /error:
Quote:
[Wed Dec 21 22:12:50 2011] [error] [client 127.0.0.1] client denied by server configuration: /opt/apache/htdocs/website
[Wed Dec 21 22:12:50 2011] [error] [client 127.0.0.1] client denied by server configuration: /opt/apache/htdocs/error/403.html
Quote:
Add an index? So I would add the ifmodule for the <Directory /var/www/error> group?
No, add an index.html page in /error (even blank)


Quote:
The mod_rewrite does make sense... any idea where I should be looking to find it?
It should be in a .htaccess in the root directory of wordpress. I guess this is the /website in your case

Regards
 
Old 12-22-2011, 12:41 PM   #11
Silver565
Member
 
Registered: Jul 2007
Distribution: Ubuntu, Windows, Freenas
Posts: 96

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by bathory View Post
No, what I'm trying to tell you, is that you should get a 403 error 2 times at the same moment. One for the /website and the other for the /error/403.html (the latter shouldn't happen and it's the problem you're facing, if I understand well your 1st post). You don't get the 2nd error, so apache looks that it works as expected, and gives you the 403 error page!!!
I've tried to do the same setup here (using different docroot), so you should get the following if there was a problem with /error:



No, add an index.html page in /error (even blank)


It should be in a .htaccess in the root directory of wordpress. I guess this is the /website in your case

Regards
Thank you for that

I haven't found an htaccess file in the root directory of wordpress, I've searched and even used "ls" in case it was hidden in the GUI search.

I've uploaded 3 pictures. One is from ".150" which is allowed to access the wordpress directory(chrome images), the other two are from my test VM which isn't on the allow list (therefore denied). Both computers can get to the error document when typing the direct path, however when I change the path to "/error/403.html" in the virtual host file, only the computer on the allow list will be given the error document when navigating to http://172.25.0.165 (which is blocked as per the config file in post #1).

The permission error shouldn't happen for the error/403.html file as I allowed "all" to that directory(/var/www/error). Which is correct, as giving the 403 error document a path of "http://172.25.0.165/error/403.html" works. However giving /error/403.html as the path for the "error document" doesn't work for addresses not listed as allowed in the virtual host file.

I know it has to be a permission problem, I'm just struggling to find out where that issue is.
Attached Thumbnails
Click image for larger version

Name:	yes.JPG
Views:	14
Size:	42.7 KB
ID:	8681   Click image for larger version

Name:	No.JPG
Views:	15
Size:	61.6 KB
ID:	8684   Click image for larger version

Name:	yes(15).png
Views:	13
Size:	23.2 KB
ID:	8685  
 
Old 12-22-2011, 01:30 PM   #12
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,174
Blog Entries: 1

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
Hi,

Quote:
I haven't found an htaccess file in the root directory of wordpress, I've searched and even used "ls" in case it was hidden in the GUI search.
Mind that it's .htaccess (with a dot in the beginning), meaning the file is hidden from ls. Try "ls -la", because AFAIK wordpress uses .htaccess to rewrite URLs.


Quote:
The permission error shouldn't happen for the error/403.html file as I allowed "all" to that directory(/var/www/error). Which is correct, as giving the 403 error document a path of "http://172.25.0.165/error/403.html" works. However giving /error/403.html as the path for the "error document" doesn't work for addresses not listed as allowed in the virtual host file.
I've already told you, that it's correct. Besides I've simulate your setup here and it worked as expected (see my previous post).
That's why I think it's a .htaccess involved. Unless you're using a proxy (unlikely) to access your server and you get cached responses from it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache2: Access forbidden! Error 403 vous Linux - Server 4 10-11-2011 04:46 AM
[SOLVED] Cgi-bin error 403 Forbidden You do not have permission to access this document. samguy Linux - Newbie 13 06-02-2010 02:04 AM
403 forbidden error with apache2 shifter Programming 4 01-22-2010 05:22 AM
403 forbidden error with apache2 shifter Linux - Networking 1 01-20-2010 02:56 PM
apache2 403 error eagletalontim Linux - Software 2 01-03-2006 10:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 04:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration