Implementing IP/Name-based Virtual Servers etc.

I am trying to implement mixed IP/Name-based virtual servers on my RedHat 6.0 linux machine but I can't seem to make it work. I tried the examples in the apache documentation but it did not work.  Other than placing VirtualHost declarations in the httpd.conf file, are there other config files that i need to modify for the virtual servers to work?

The linux box i am working on is connected to a LAN whose domain name i do not want to use. I just need to be connected so that i could have access to the internet. Other than that, i don't need to be connected to this LAN and given the choice, I wouldn't. I am having problems because of this connection to the LAN. Whenever I try to access my local web server (localhost.localdomain), i need to type the IP address to access it. If I type the localhost name, it first searches in the DNS located in the LAN server. How could I fix this so that it would need to check the LAN server DNS first if the host i type is the local host?

To summarize, my questions are:
- what are the config files that i need to modify and how should they be modified in order to implement virtual servers?
- how can i make my server check the local machine first before going to the LAN server DNS?

Thanks.
wsanchezAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SokkaConnect With a Mentor Commented:
1. /usr/local/apache/conf/httpd.conf
     is the config file

2. /etc/resolv.conf - first entry local lan IP
                      Second entry remote IP
0
 
jlevieCommented:
I believe that there's a /etc/nsswitch.con file on your system that contains a "hosts" entry which specifies the order in which hostnames will be resolved. On RH 6.1/6.2 the default entry looks like:

hosts:      files nisplus nis dns

Which says that the system should look in the local hosts file before consulting the DNS. So if you have the entry:

127.0.0.1      localhost.localdomain localhost

in your /etc/hosts file you won't use dns to resolve that name. There also needs to be a separate entry for the official name of the system, perhaps something like:

111.222.333.444      my-offical.name.com my-official

where the IP is that assiged to your system (assuming a static IP) and the FQDN is that as returned by an nslookup of your IP. If you have a dynamically assigned IP, the DHCP process should take care of the hostname for you.

As to creating virtual servers. You can create any named virtual servers that you like in Apache. If you make aliases in your hosts file for those names, like:

111.222.333.444      my-offical.name.com my-official virt1.srv.com virt2.srvit.com

then from your system, and your system only, you'll be able to access URLs that use those FQDNs. If you wish to access virtual servers from other than the local system, records must be added to the DNS server(s) that host those virtual domains to point to your system.
0
All Courses

From novice to tech pro — start learning today.