PDA

View Full Version : How to get multiple IP addresses for one port?


Phil St. Romain
04-22-2004, 10:10 PM
Using Mac OS X Server, v. 10.1. The Apple info base article on how to do this is missing from their database.

What I've done:
1. Open Network Prefernces
2. Show: Active Network Ports
3. Duplicate Built-in Ethernet
4. Rename as Ethernet 2
5. Show: Ethernet 2
6. Change IP address in Ethernet 2, leaving all else the same.

Back to Web Services in Server Admin. where I assigned a second domain to port 80 and the IP address of Ethernet 2 config.

Result: Domain 2 still doesn't go to its folder, but goes to Domain 1 and Built-in Ethernet IP.

What did I do wrong?

Phil St. Romain
04-23-2004, 09:35 AM
Seems I've been stumping the panel lately. ;)

So let's try this: how do you host multiple Internet domains on Mac OS X Server? That's what I'd like to do. Assigning each it's own IP address is what the Server Admin book I got with the software recommends. Is there another way?

yellow
04-23-2004, 09:36 AM
I'm stumped. I didn't think 2 IP addresses could be assigned to 1 NIC.

So by "domains" do you mean the literal translation, or separate web domains?

hschickel
04-23-2004, 11:48 AM
Phil,

Do you have multiple public addresses or are you assigning multiple internal network addresses? AFAIK, if you're doing this with only internal addresses you'll need to also setup DNS.

If you're setting up private addresses (w/o DNS) what happens if you hit the private address from within your network?

Hugh

Phil St. Romain
04-23-2004, 02:57 PM
Thanks, yellow and Hugh, for your responses.

I've got several domains registered with Network Solutions. They're being hosted in different places and I'd like to bring them all onto my computer. I have a static internet IP address and a business account, so that's all square.

I set up user accounts for the web domains on X Server and tried to assign them to different LAN IP addresses created as noted above. This is what the X Server Admin. manual says to do. I thought Web Services would route requests for the different domains to the correct folders I associated with those LAN IP addresses, but no-go: everything goes to the Server Admin IP address.

Here's what p. 305 in the Admin. manual says: "On some occasions, you may want to configure multiple IP addresses for a particular port. For example, if you use the server to host multiple web sites, you may want to accept requests for different domains (URLs) on the same port. To do so, you need to set up the port to have multiple configurations, one for each domain name, then use the Web module of the Server Admin to map each site to a particular configuration." They then outline the steps to set up multiple LAN IP addresses for a particular port, and I followed them (top post). I also set up port forwarding on my router so that port 80 would open to all of them. It doesn't work, however.

In addition to the above, maybe I should set a different port besides 80 for each domain. But would a web browser be able to find the site? Would the Web Server take care of that?

Yeah . . . new to doing multiple domains.

yellow
04-23-2004, 03:09 PM
Hmm, so it sounds like all you need is to set up redirection for web traffic destined for a particular DNS entry, not necessarily a unique/multiple IP address for your single NIC. I know this is possible, but how? I don't know. YET! I'm off to Google..

1 clue to look for: host field mapping

Is this what you're looking for: http://httpd.apache.org/docs/vhosts/mass.html

shaman
04-24-2004, 10:47 AM
Just open terminal, go root and enter:

ifconfig eee xxx.xxx.xxx.xxx netmask yyy.yyy.yyy.yyy alias

where:
eee is your ethernet adapter /normal en0/
xxx.xxx.xxx.xxx is the IP you want
and
yyy.yyy.yyy.yyy apropriate netmask

if you want to remove the other ip's enter:

ifconfig eee xxx.xxx.xxx.xxx netmask yyy.yyy.yyy.yyy -alias

Phil St. Romain
04-24-2004, 11:52 AM
Thanks. I went through those steps as described
here (http://docs.info.apple.com/article.html?artnum=60301), which seems to be saying the same thing you are. Still no go.

Edit: I can ping the new IP address just fine, but it seems my router will only do forwarding on port 80 to one IP address. Time to study DNS, I guess. :(

shaman
04-24-2004, 01:07 PM
Edit: I can ping the new IP address just fine, but it seems my router will only do forwarding on port 80 to one IP address. Time to study DNS, I guess. :(

If you enter in terminal :

netstat -tna

you will see this (among others):

tcp4 0 0 *.80 *.* LISTEN


that means.. The server listens on ALL availible IP addresses on port 80.

If you want different WEB sites to have different IP's you have to specify it in "Web" on your "Server Admin".app
and each name have to be resolvable... i mean each IP must have name. This is made by DNS !

Phil St. Romain
04-24-2004, 01:54 PM
Right. But my router only forwards port 80 info to one IP address. I'm sure of that now.

I have one domain registered to my internet IP address and a homeip.net subdomain pointing to the same. I've been trying to get both to work by assigning them different LAN IP addresses in Web Services. The one that works is the first one port 80 is forwarded to in the router; if I change the order in forwarding in the router, the other works.

aixccapt99
04-25-2004, 02:47 PM
Don't use IP-based virtualhosting, use name-based virtualhosting. The apache manual is a little confusing about this, but basically, you end up telling apache to check the HTTP request and see how it's being addressed (this is HTTP 1.1 only, doesn't work for 1.0), and switch virtualhosts based on that string.

Here's how I do it:

In /etc/httpd/httpd.conf:
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>

<VirtualHost *>
# use the basic host (defined above) for all unknown requests
ServerName ebhjcl.homedns.org
DocumentRoot "/Library/WebServer/Documents"
</VirtualHost>

# Other virtualhosts are defined in include files
Include /private/etc/httpd/vhosts/*.conf

You could define all the vhosts at the end of the httpd.conf, but I have a couple domains, with a few subdomains each, so I thought it was easier to split them out into separate files. Here's one of those:

# this file is included by /etc/httpd/httpd.conf
# it contains virtualhost definitions for mysubdomain.homedns.org

# rewriting test
<VirtualHost *>
ServerName rd.mysubdomain.homedns.org
DocumentRoot "/Library/WebServer/rewrite/rewriter.php"
<Directory "/Library/WebServer/rewrite/">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
UserDir disabled
#RewriteEngine on
#RewriteRule ^(.*) /rewriter.php
</VirtualHost>

# html tests for mydomain.com
<VirtualHost *>
ServerName eb.com.ebhjcl.homedns.org
DocumentRoot "/Library/WebServer/mydomain_com"
<Directory "/Library/WebServer/mydomain_com/">
Options Indexes
AllowOverride None
Order allow,deny
Allow from all
</Directory>
UserDir disabled
</VirtualHost>

<VirtualHost *>
# syntax test
ServerName syntax.mysubdomain.homedns.org
DocumentRoot "/Library/WebServer/syntax_www"
<Directory "/Library/WebServer/syntax_www/">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all

php_flag register_globals on

</Directory>
UserDir disabled
</VirtualHost>

So like that. The ServerName is the canonical name the server should be known by and should respond to. You can specify alternate names for each virtualhost by listing them in a ServerAlias directive.

The first matching virtualhost is used. This is important if you use a wildcard (ie ServerAlias *.mysubdomain.homedns.org) -- put that last, or else your specific subdomains won't ever be seen. If no virtualhost names match, the first virtualhost is used -- that one is defined in the main httpd.conf, and is the same as the default server config.

Phil St. Romain
04-25-2004, 07:13 PM
Thanks aixccapt99. That's a very thorough reply and I'll experiment with it sometime. Doing all that work in the Terminal was one of the things I was hoping Mac OS X Server would alleviate, but maybe there's not getting around it.

Phil St. Romain
04-30-2004, 08:33 PM
Update, I haven't gotten the two domains to work together using IP aliases, but I have gotten subdomains to work off of one domain. It's actually easy. First, create new Users for each subdomain and then create new sites in the Web server admin. as follows:
mydomain.com - assign port 80 and LAN IP address.
subdomain1.mydomain.com - same port and LAN IP
subdomain2.mydomain.com - same port and LAN IP
Assign each subdomain its respective Sites folder in its User directory in the configuration.

This info isn't kept /etc/httpd/httpd.conf, but in
/etc/httpd/httpd_macosxserver.conf

This isn't very well spelled out in the Admin manual, which pretty much seems to say that a separate IP is required for each site or else DNS. There's no clarification on this forum either. So, hopefully, anyone searching for how to set up subdomains on OS X Server can find some help here. This only applies for subdomains on a registered domain that has DNS hosted somewhere else.

drpeanut
03-07-2010, 06:42 PM
Sorry to ping an old post, but the procedure has changed a bit and I needed to add a second IP address in OS X Snow Leopard.

Here is a link to a blog post on how to add multiple IP addresses to snow leopard (http://www.macminiworld.net/blog/multiple-ip-address-in-mac-os-x-snow-leopard/).

Goodluck everyone!