Help: setup name-based or port-based virtual web host.

Help: setup name-based or port-based virtual web host.

Post by Juping J » Mon, 28 Jun 1999 04:00:00



I hope I post the question at correct place. If not, please forgive me.

I am running Slackware linux 4.0 with Apache 1.3.6, and would like to setup
virtual hosts.

Following the documentation coming with apache, first I tried name-based.
At the end of httpd.conf, added the following lines:
(I only tested it with loopback address)

NameVirtualHost 127.0.0.1

<VirtualHost 127.0.0.1>

        ServerName www.test.com
        DocumentRoot /home/myaccount/public_html
        ....
</VirtualHost>

<VirtualHost 127.0.0.1>

        ServerName www.another.com
        DocumentRoot /home/another/public_html
        ...
</VirtualHost>

Then I fired up apache server, run netscape, open http://www.test.com.
The browser complained that it cannot resolve name www.test.com. So I added
above two name in /etc/hosts, both point to 127.0.0.1. Restart apache server
and browser. Now both virtual hosts points to main_server's root (say,
/usr/local/apache/htdocs), not the location specified in VirtualHost section.
Aparantly, DocumentRoot in VirtualHost section did not take effect. And
apache documentation didn't say that those names should appear in /etc/hosts
file.

Next, I tried port-based virtual hosts. Added Listen directives in main part
and put respective port number for each virtual host as:
<VirtualHost 127.0.0.1:port#>, kept others the same. After fired up server and
browser, I can only open the location as specified 127.0.0.1:port#, but not
the name as www.test.com (without putting them in /etc/hosts file), although
this time, they pointed to correct locations specified by DocumentRoot.

Could someone point out what I did wrong? Your time and suggestions are highly
appreciated.

juping

 
 
 

1. Appropriate HTTP Error Code for "No Default Host" in Name-Based Virtual Host Setup

I am hosting several web sites at the same IP address and I don't intend
to provide a default host.

(Example: Let's say I am hosting www.foo.tld and www.bar.tld at
10.20.30.40. I want to show an appropriate error message for all
requests to http://10.20.30.40, i.e., any requests that don't use a FQHN.)

Obviously, I could declare a default host that serves a single HTML file
with a message such as, "Please always use the FQHN when requesting web
pages hosted at this address" (or sth to that effect), but that would
automatically send a 200 code with the response, which doesn't strike me
as correct.

I am not quite sure what HTTP error code to generate. Several candidates
look like they mey be appropriate, e.g.,

403 Forbidden
409 Conflict
501 Not Implemented

Any input?

Thanks,
Thorsten

2. HUB/Router Speed?

3. Name-based vs IP based virtual hosts

4. Installation problems with RED hat linux 7.1 and 7.2

5. Mixing IP-based and name-based virtual hosts?

6. Using a JVC DAT

7. Can IP-based and Name-Based Virtual Hosting coexist

8. How to disable incoming ICMP-Pings on router through proc-sys.

9. Setting up IP-based and Name-based virtual hosting side by side...

10. name based vi IP based virtual hosts

11. Mixing Apache Name Based Virtual Hosts and SSL Virtual Host

12. name and port based virtual hosts

13. Setting up Name-Based Virtual Hosts with Apache in RH7