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!

2 Domains 1 IP 1

Status
Not open for further replies.
Apr 27, 2006
126
GB
I can see how setting up a virtual domain looks easy enough, almost TOO easy, which is why I wanted to double check before I kill my websites.

I have 2 domains, one (Site A) is running on a virtual linux server with 1 IP address (and it's running as a vhost). The other (Site B) is currently just web forwarding to a sub-folder within my httpdocs.

I want to totally split the two sites but only have 1 IP.

Would the following steps be correct (and actually work)?

*Change Nameservers of webforwarding (Side B) domain to my new hosts
*Add a dns record on my server for Site B
*Add a vhost (using plesk it should just be a couple of clicks if i recall correctly) relating to the SiteB domainname
*Cross my fingers and wait for everything to work/die

Am I along the right tracks and if this will work, will this work without any problems?

Cheers

________
clueless
 
Yes, provided you they aren't https/SSL, and you used all relative names in your linkage.

You should be able to add a test virtual host with a distinct name. Then you can test it using a local hosts change to see if there are problems. Once those are resolved, then you can do the DNS change.
 
how would I go about testing it if the domain name isn't set on the server and the server only has 1 IP? If i do to domainname.net it will just direct me to the main site won't it? Heh, if there are no easy follow guides i'll probably just do what i always do, pull my hair out until I get it working due to sheer look and no skills :)

Gah, who's bright idea was setting up an online game anyway? lol

________
clueless
 
You subvert the DNS for one machine. On linux, you simply edit /etc/hosts and add your entry; most use /etc/hosts before DNS or NIS so it supplants the lookup.

1.2.3.4
Same with a windows machine, but the path to hosts file can be different:

Windows 95/98/Me c:\windows\hosts

Windows NT/2000/XP Pro c:\winnt\system32\drivers\etc\hosts

Windows XP Home c:\windows\system32\drivers\etc\hosts

Edit the file, save with no extension type text.

The change should be immediate on both Unix and Windows, no reboot required.

Now that machine (and only that machine) will think is at IP 1.2.3.4 and a browser will also be fooled.
 
Here is a code sample. Depending on your configuration this will either go in httpd.conf or vhosts.conf. There may be some glaring security holes in here, but I'm not running anything mission critical and just wanted it to work.


<VirtualHost _default_:*>
DocumentRoot /var/</VirtualHost>

NameVirtualHost w.x.y.z

###
### Configuration for somesite.org
###

<VirtualHost w.x.y.z>
ServerName ServerAlias somesite.org
ServerPath /var/DocumentRoot /var/
DirectoryIndex index.html index.cgi index.shtml index.htm index.php index.pl
ErrorLog logs/somesiteerror.log
CustomLog logs/somesite.log combined

AddHandler cgi-script .cgi .pl

<Files *.pl>
AllowOverride None
Options +ExecCGI
Order allow,deny
allow from all
</Files>

ScriptAlias /cgi-bin/ /var/
</VirtualHost>



The 'NameVirtualHost' entry comes only once. You can repeat everything between the <VirtualHost w.x.y.z> and </VirtualHost> for as many domains as you need. w.x.y.z is always the same and is the IP of your server. If you had more than one network card and more than one IP you could set up named virtual hosts differently for each IP - just copy the whole configuration (including the NameVirtualHost) for each IP your server responds to.

Hope that helps. Sorry I made it generic - if I do have any mistakes in there I didn't want to advertise my IP or domains to the world!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top