Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running several sites through a router - httpd.conf ignored? 1

Status
Not open for further replies.

jonny201

Technical User
Jun 11, 2006
4
BR
I'm running Apache on a Mac, with 4 websites on it.

Up until recently, it has been directly connected to my DSL modem, with the fixed IP my ISP gave me. This works fine - the 4 sites are defined in the httpd.conf file, and they're all OK.

I am trying to put a Linksys wireless router into the mix now, and have a problem.

Here's what I have done, and what works;

I have put the fixed IP address into the router, set the DHCP range to start from x.x.x.101 for DHCP clients. I have set the webserver with a fixed IP of x.x.x.100 (it's 192.168.1.100, but I'll use x to save keep typing it).

I have forwarded ports 80 and 21 on the router for ip 100 (the server).

The router is giving IP addresses to clients, they're connecting to the internet OK. The server is also connecting OK.

What isn't working - if I try to navigate to any of my 4 sites, using a browser, the server is pointing to the wrong place - it's pointing to macharddisk/library/webserver/documents which if I recall is the Apache default.

The server directives in httpd.conf (which work with the direct connection) are on another hard disk.

So, for any of the sites, it just points at that location. It seems to ignore the httpd.conf file.

I have altered the httpd.conf file from the ISP ip address to 192.168.1.100

It looks something like below, but pointing a browser at any of the sites just goes to the one I have temporarily put in the webserver/documents directory:

NameVirtualHost 192.168.1.100

<VirtualHost ServerName DocumentRoot /volumes/data/web/site1
</VirtualHost>

<VirtualHost ServerName DocumentRoot /volumes/data/web/site2
</VirtualHost>

<VirtualHost ServerName DocumentRoot /volumes/data/web/site3
</VirtualHost>

<VirtualHost ServerName DocumentRoot /volumes/data/web/site4
</VirtualHost>


Any ideas? TIA
 
Your Virtual Host's should be set-up like this.
Code:
NameVirtualHost 192.168.1.100:80

<VirtualHost 192.168.1.100:80>
    DocumentRoot /volumes/data/web/site1
    ServerAdmin admin@site1.net
    ServerName [URL unfurl="true"]www.site1.net[/URL]
    ServerAlias site1.net
    CustomLog /path/to/log/access_log combined
    ErrorLog /path/to/log/error_log

    <Directory />
        Options ALL
        AllowOverride ALL
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

M. Brooks
 
Thanks.

That is now pointing at the correct location - which is half the problem solved.

Is it possible that I can specify more than one site though?

I just tried changing

<VirtualHost 192.168.1.100:80>

to

<VirtualHost
And it went back to misbehaving (you can see I don't really know what I'm doing . . .).

The real issue I'm hoping to solve is how to run more than one site - I also have etc.

Although your post has got the server looking in the right place, which is a big relief, I'm still a bit stuck.

Thanks a lot.
 
Code:
NameVirtualHost 192.168.1.100:80

<VirtualHost 192.168.1.100:80>
    DocumentRoot /volumes/data/web/site1
    ServerAdmin admin@site1.net
    ServerName [URL unfurl="true"]www.site1.net[/URL]
    ServerAlias site1.net
    CustomLog /path/to/log/access_log combined
    ErrorLog /path/to/log/error_log

    <Directory />
        Options ALL
        AllowOverride ALL
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost 192.168.1.100:80>
    DocumentRoot /volumes/data/web/site2
    ServerAdmin admin@site2.net
    ServerName [URL unfurl="true"]www.site2.net[/URL]
    ServerAlias site2.net
    CustomLog /path/to/log/access_log combined
    ErrorLog /path/to/log/error_log

    <Directory />
        Options ALL
        AllowOverride ALL
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

<VirtualHost 192.168.1.100:80>
    DocumentRoot /volumes/data/web/site3
    ServerAdmin admin@site3.net
    ServerName [URL unfurl="true"]www.site3.net[/URL]
    ServerAlias site3.net
    CustomLog /path/to/log/access_log combined
    ErrorLog /path/to/log/error_log

    <Directory />
        Options ALL
        AllowOverride ALL
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
Etc, etc, etc...

M. Brooks
 
You only need to specify the port if you are going to have more than one port used.
ex:
instead of
NameVirtualHost 192.168.1.100:80

<VirtualHost 192.168.1.100:80>
ServerName xxxxxx ...
</VirtualHost>

You could use

NameVirtualHost 192.168.1.100

<VirtualHost 192.168.1.100>
ServerName xxxxxx ...
</VirtualHost>

or even
NameVirtualHost *

<VirtualHost *>
ServerName xxxxxx ...
</VirtualHost>
 
Yes, the ServerName directive is what the virtualhost compares to the URL, not what is in the VirtualHost directive.

Also remember that the first one is the default, if it
doesn't match and ServerName...

gene
 
OK, thanks a lot for all your help here. I'm going to try it when I get home tonight, I'll let you know how I get on.
 
Thanks a lot folks, it's all working perfectly now.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top