LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 11-14-2007, 01:30 PM   #1
Kage6060
LQ Newbie
 
Registered: Nov 2005
Posts: 15

Rep: Reputation: 0
website aliasing in Slack 11


here is my task


IP=192.168.10.<#>

www.<lastname>.org produces a page that says "Happy Holidays from <lastname>.org domain"

and

www.<lastname>.net produces a page that says "Happy Holidays from <lastname>.net domain".



I'm not really sure how to go about doing this. I've heard from a few people that it would be done using iptables. Any help would be great.
 
Old 11-15-2007, 12:53 PM   #2
Mugsy69
LQ Newbie
 
Registered: Oct 2007
Posts: 6

Rep: Reputation: 0
Best bet is Apache Virtual hosts

Try something like the following in your httpd.conf (syntax specific to apache):

NameVirtualHost 192.168.10.#

<VirtualHost 192.168.10.#>
ServerName www.<lastname>.org
DocumentRoot /www/<lastname>.org
</VirtualHost>

<VirtualHost 192.168.10.#>
ServerName www.<lastname>.net
DocumentRoot /www/<lastname>.net
</VirtualHost>

Change "/www/<lastname>.net|org" to where ever you want your document roots to live and put the correct ip address in the appropriate places. There are other options for the <VirtualHost> block but these are the minimum you'll need to get them to respond as seperate sites on the same IP. Oh, and you'll need to have A records in DNS for www in both domains pointing the same IP address or, of course, entries in the hosts file on the machines that need to find the servers.

For more info check the apache docs at apache.org.
 
Old 11-16-2007, 02:04 PM   #3
Kage6060
LQ Newbie
 
Registered: Nov 2005
Posts: 15

Original Poster
Rep: Reputation: 0
still having trouble

The aliasing effect works. when I go to scribner.org it goes to the index.html, but when I type in scribner.net it doesn't go to index2.html. I put 2 records in the hosts file for each virtual host, and I put the following into my httpd.conf file

Code:
NameVirtualHost 192.168.10.80
 
 <VirtualHost 192.168.10.80>
 ServerName www.scribner.org
 DocumentRoot /www/scribner.org/index.html
 </VirtualHost>
 
 <VirtualHost 192.168.10.80>
 ServerName www.scribner.net
 DocumentRoot /www/scribner.net/index2.html
 </VirtualHost>
any ideas on how I can get scribner.org to display index.html AND get scribner.net to display index2.html?
 
Old 11-16-2007, 11:26 PM   #4
Mugsy69
LQ Newbie
 
Registered: Oct 2007
Posts: 6

Rep: Reputation: 0
You're almost there

What you've setup is two seperate named virtual hosts with two seperate document roots. The document root is the base folder where the sites documents live. In addition to the document root there is another directive in httpd.conf which defines the names of the default document(s) for the site. By default the list includes index.html but not index2.html. So....

"DocumentRoot /www/scribner.org/index.html" should actually be
"DocumentRoot /www/scribner.org"

and "DocumentRoot /www/scribner.net/index.html" should be
"DocumentRoot /www/scribner.net"

The default page in both those folders should be named index.html. If you really want to use index2.html you could change the VirtualHost stanza for scribner.net to look like this:

<VirtualHost 192.168.10.80>
ServerName www.scribner.net
DocumentRoot /www/scribner.net
DirectoryIndex index2.html
</VirtualHost>

I'd suggest picking up a good apache reference if you need to get any more complicated.
 
Old 11-28-2007, 03:29 PM   #5
Kage6060
LQ Newbie
 
Registered: Nov 2005
Posts: 15

Original Poster
Rep: Reputation: 0
very frustrated

I still can't get it to grab 2 different index pages. I have in my hosts file the following

Code:
127.0.0.1 localhost
127.0.0.1 www.scribner.org
127.0.0.1 www.scribner.net
192.168.10.80 scribner.scribner.org scribner
and then in my httpd.conf

Code:
NameVirtualHost 192.168.10.80

<VirtualHost 192.168.10.80>
ServerName www.scribner.org
DocumentRoot /www/scribner.org
</VirtualHost>

<VirtualHost 192.168.10.80>
ServerName www.scribner.net
DocumentRoot /www/scribner.net
</VirtualHost>
and in /var/www/ I have 2 directories, one is scribner.org and the other is scribner.net

Within both of those directories I have an index.html file that I want to be accessed respectively, when you go to scribner.org and scribner.net

I can't seem to find what's wrong with my execution. Any help would be great
 
Old 11-29-2007, 09:24 AM   #6
Mugsy69
LQ Newbie
 
Registered: Oct 2007
Posts: 6

Rep: Reputation: 0
Quote:
Originally Posted by Kage6060 View Post
Code:
127.0.0.1 localhost
127.0.0.1 www.scribner.org
127.0.0.1 www.scribner.net
192.168.10.80 scribner.scribner.org scribner
This is fine although it won't work off the server. I'm assuming, for the sake of this exercise, that 192.168.10.80 is the actual external address of the server. The problem you're having is you have apache configured to listen on 192.168.10.80 but you're hitting the server over 127.0.0.1 so you're getting the default docroot every time.

Quote:
Originally Posted by Kage6060 View Post
Code:
NameVirtualHost 192.168.10.80

<VirtualHost 192.168.10.80>
ServerName www.scribner.org
DocumentRoot /www/scribner.org
</VirtualHost>

<VirtualHost 192.168.10.80>
ServerName www.scribner.net
DocumentRoot /www/scribner.net
</VirtualHost>
I would recommend changing the above to one of the following:

Code:
NameVirtualHost *

<VirtualHost *>
ServerName www.scribner.org
DocumentRoot /www/scribner.org
</VirtualHost>

<VirtualHost *>
ServerName www.scribner.net
DocumentRoot /www/scribner.net
</VirtualHost>
The above will cause the server to work the same on every IP address bound to the machine. Option 2 would be:

Code:
NameVirtualHost 127.0.0.1
NameVirtualHost 192.168.10.80

<VirtualHost 127.0.0.1 192.168.10.80>
ServerName www.scribner.org
DocumentRoot /www/scribner.org
</VirtualHost>

<VirtualHost 127.0.0.1 192.168.10.80>
ServerName www.scribner.net
DocumentRoot /www/scribner.net
</VirtualHost>
The above will cause apache to respond correctly for the two sites on both the loopback (127.0.0.1) and external (192.168.10.80) address but not any other address that might be bound to the machine. Good luck and I'd suggest that you might consider reading the manual if you need more help. It's pretty clear and has some good examples here.
 
Old 11-29-2007, 09:30 AM   #7
Mugsy69
LQ Newbie
 
Registered: Oct 2007
Posts: 6

Rep: Reputation: 0
BTW, I just reread one of your earlier posts. If you have your documents in /var/www/scribner.org and /var/www/scribner.net respectively then you need to change your httpd.conf as follows:
Code:
<VirtualHost 127.0.0.1 192.168.10.80>
ServerName www.scribner.org
DocumentRoot /var/www/scribner.org
</VirtualHost>

<VirtualHost 127.0.0.1 192.168.10.80>
ServerName www.scribner.net
DocumentRoot /var/www/scribner.net
</VirtualHost>
The document root setting is the actual path to your documents and is relative to the actual root of the file system.
 
  


Reply

Tags
apache2conf, virtual host



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ip aliasing zerg4141 Linux - Networking 1 04-19-2007 05:52 PM
slack website and next version rgiggs Slackware 4 04-21-2004 09:14 AM
Ip Aliasing joseph Linux - Software 2 09-26-2003 11:52 PM
IP Aliasing nyek Linux - Networking 2 12-26-2001 07:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:58 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration