Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an odd problem when attempting to browse to pages stored on a local web server (Apache 2.2). The pages are served as expected when I browse to localhost or 127.0.0.1 on port 80. Yet when I attempt to browse to the same pages by referencing the local IP address (192.168.x.x), I receive a HTTP 403 (Forbidden) error. In essence, http://localhost:80 works but 192.168.x.x:80 doesn't even though I'm specifying the IP of the local machine. You may be thinking "who cares? just use localhost". However, this is the first step in troubleshooting why I cannot remotely access these pages from different hosts on my LAN.

I'm presuming this can't be a firewall issue as I'm only connecting to the local machine. Even so, I verified there was no iptables rules that could be having an effect.

I've checked the Apache error logs and the corresponding line of relevance is:

[Sat Oct 19 07:38:35 2013] [error] [client 192.168.x.x] client denied by server configuration: /var/www/

I've inspected most of the apache config files and they don't appear to differ from what you would expect with a default install. I can't see anything in apache2.conf that would be a problem and httpd.conf is an empty file. This is an excerpt from /etc/apache2/sites-enabled/000-default:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www
    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

Any insight as to where I can look next to find a solution ?

Thanks in advance.

share|improve this question
    
What is the contents of .htaccess in the /var/www/ folder? –  Barry Carlyon Oct 19 '13 at 13:36
    
@BarryCarlyon Thanks, that was it. .htaccess files were not configured as expected. Feel free to post your comment an answer so I can accept it. –  amjo324 Oct 19 '13 at 22:05
add comment

2 Answers

up vote 1 down vote accepted

As requested.

The next thing to check since your httpd.conf/vhost is correct, is the .htaccess file found in the directory in question.

Httpd.conf/vhost is applied first and subsequently overruled by .htaccess in the requested folder (as permitted by the httpd.conf/vhost in the first place). So my theory is that a rule in there is causing the permission error.

share|improve this answer
add comment

As per your description I am assuming you are using Apache a Debian based system. I think httpd is not listening on you 192.168.x.x IP address. It is listening only on localhost. You can verify it using following command.

netstat -tulpn | grep :80

I think you will see 127.0.0.1:80 in the output. If yes, then check /etc/apache2/ports.conf file. You should use Listen 80 in the file to ask httpd to listen on all IP addresses. Refer following links.

http://httpd.apache.org/docs/2.2/bind.html http://httpd.apache.org/docs/2.2/mod/mpm_common.html#listen

share|improve this answer
    
Thanks for your input. I'd already checked my ports.conf file and it specified Listen 80. Also, httpd was listening on the 'catch all address' of 0.0.0.0. Turns out it was .htaccess files that were the problem as per Barry's suggestion. –  amjo324 Oct 19 '13 at 21:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.