The issue is the Virtual host settings in our httpd.conf file gets recognised inside the server. If I type the IP (name server defined in httpd.conf)inside my server, the IP gets redirected to the path mentioned in the conf file. But when I access the same Ip from an external machine, I go to the Redhat default page.

The paths var, var/www,var/www/html all have 777 access permission.

We are using
RHEL Version 5

Settings in httpd conf********

NameVirtualHost n.n.n.n:80


ServerAdmin n.n.n.n
Servername n.n.n.n
DocumentRoot "/var/www/html/mysite"

**********END of httpd.conf

N.n.n.n from outside the server takes me to the redhat default page, where as n.n.n.n/mysite works.

The error that i get in my log is "Directory index forbidden by option directive:var/www/html"

Comments

jfxberns’s picture

Sorry after reading my last post I think I missed your point--so I deleted and rewrote it. Here is what I think you were looking for.

Does your httpd.conf have a directive like this?

<Directory "/var/www/html">
    Options Indexes FollowSymLinks MultiViews
</directory>

The Indexes option will allow apache to show the files and subdirectories.

That is, if your apache has the mod_autoindex module installed.

John Berns
Travel Guide
Travel Photographer

Shyamala’s picture

Thanks for your support.We solved the issue by setting
this

Name VirtualHost *:80

<VirtualHost *:80>
ServerName n.n.n.n
DocumentRoot /www/domain
</virtualHost>

We are unable to access url://n.n.n.n from inside the
host machine. This problem surfaced yesterday, even
before we made the above mentioned settings. What are
the reasons for inability to access IP from inside
host. Thanks once again for your prompt support.

Shyamala
Team Leader (http://www.netlinkindia.com)

gonefishing’s picture

"We are unable to access url://n.n.n.n from inside the
host machine"

What happens when you enter localhost or 127.0.0.1 in the address bar of the host machine?

jfxberns’s picture

For starters, you seem to be confusing Named Virtual Hosts with IP-based virtual hosts. n.n.n.n is not a server name, it's an IP address; www.domain.com or dev.domain.com is a server name.

I can see you are already running into a mess with this server configuration strategy. I think you are better off moving to using domain names rather than IPs to develop and test your sites.

I never just use IPs for development. I use names like "dev.somedomain.com" "sandbox.anotherdomain.com" and I either have those names resolved by a local DNS server--or if I am just working on a couple of sites by myself I keep things simple and edit the /etc/hosts files on the local machines.

Here is how the httpd.conf and hosts files would look:

Named Virtual Hosts section from httpd.conf

### Section 3: Virtual Hosts
#
# Use name-based virtual hosting.
#

NameVirtualHost 192.168.222.41:80

<VirtualHost 192.168.222.41>
    DocumentRoot /home/somedomain-dev/public_html
    ServerName dev.somedomain.com
    ErrorLog logs/dev.somedomain.com-error_log
    CustomLog logs/dev.somedomain.com-access_log common
</VirtualHost>

<VirtualHost 192.168.222.41>
    DocumentRoot /home/anotherdoman-sandbox/public_html
    ServerName dev.anotherdoman.com
    ErrorLog logs/dev.anotherdoman.com-error_log
    CustomLog logs/dev.anotherdoman.com-access_log common
</VirtualHost>

Then I create a /etc/hosts file like this on the server (this is hosted on a linux box; windows has a similar hosts file, see below):

Do not remove the following line, or various programs
# that require network functionality will fail.

127.0.0.1	     localhost.localdomain            localhost

#
# Websites on Development Server 192.168.222.41
#

192.168.222.41	  dev.somedomain.com             dev
192.168.222.41	  sandbox.anotherdomain.com    sandbox

#
# Websites on Test Server 192.168.222.42
#

192.168.222.42    test.somedomain.com             test

The windows hosts file located at C:\WINDOWS\system32\drivers\etc\hosts, but the file layout is a little different, if you look at the file you should be able to figure out what to do--it's that basic.

John Berns
Travel Guide
Travel Photographer