[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Trouble configuring apache to listen to second IP in same instance

Posted on 2004-12-01
5
Medium Priority
?
397 Views
Last Modified: 2010-03-04
I'm trying to establish a virtual host using a second IP on the same box.
I'm using redhat Fedora Core 2, and the IP's are pointed at the machine externally.  I'm not sure if my problem is with binding the IP's or in establishing the virtual host in my config file.

My 2 IP's are xx.xx.xx.26 and xx.xx.xx.27 and port 80 is available on each.  One I would like to assign to a named address of www.mydomainname.net and the other to www.mydomain.com  the .net I would like to send to a folder in var/www/dotnet and the dotcom to the default of var/www/html
I'd like to send the error logs to different folders named /logs/dotnet and /logs/dotcom

When I check the hardware settings in the network configuration, I only show the .26 address  and I'm not sure how to get the hardware nic to listen to the .27 address the ISP has pointed at the line.

Can you help?
0
Comment
Question by:preserver3
  • 3
5 Comments
 
LVL 1

Author Comment

by:preserver3
ID: 12718047
I have both IP's established in the network configuration, but when I attempt to start apache with a name based virtual host I get
[Wed Dec 01 11:54:01 2004] [error] (EAI 2)Name or service not known: Failed to resolve server name for xx.xx.xx.xx.26 (check DNS) -- or specify an explicit ServerName

When I try to switch to listen to the ports exclusively instead of the global listen to port 80 ie:
Listen xx.xx.xx.26:80
Listen xx.xx.xx.27:80
I get a server denial message from the page
and when I implement the virtual hosts with
<VirtualHost xx.xx.xx.27:80>
    ServerAdmin jasonstarin@giant-head.com
    DocumentRoot /var/www/dotnet
    ServerName www.mysite.net
    ErrorLog /etc/httpd/dotnetlogs
</VirtualHost>
<VirtualHost xx.xx.xx.26:80>
    ServerAdmin me@mydomain.com
    DocumentRoot /var/www/html
    ServerName www.mysite.com
    ErrorLog /etc/httpd/dotcomlogs
</VirtualHost>

I get this error:
(98)Address already in use: make_sock: could not bind to address [::]:80
no listening sockets available, shutting down
 if I leave it listening to 80 or this error if I don't:
 (EAI 2)Name or service not known: Failed to resolve server name for xx.xx.xx.27 (check DNS) -- or specify an explicit ServerName

Where am I going wrong?

0
 
LVL 5

Assisted Solution

by:g0rath
g0rath earned 1000 total points
ID: 12718608
You want to use IP aliasing. This is different per Linux distro, so need to know which one first.

Basically you'll be setting up

eth0:0 xx.xx.xx.26
eth0:1 xx.xx.xx.27

Look for a line to add something like this or the above
xx.xx.0.26-27

For those named instances to work, are the DNS records pointing to the .26 and .27 IPs correctly?
Your Apache config stuff there is correct, the only reason it's failing is because nothing is responding to the xx.xx.xx.27 address. After that gets resolved, you should be fine.

Note: You'll want to find the proper config way to do this....if not, these commands will always work, just not after a reboot

/sbin/ifconfig eth0:1 xx.xx.xx.27

/sbin/route add -host xx.xx.xx.27 dev eth0:1

Then to see if it looks cool:

cat /proc/net/aliases

-----
RedHat 8.0

go to the dir /etc/sysconfig/network-scripts
look for files that look like "ifcfg-eth0" etc...

copy the file ifcfg-eth0 to ifcfg-eth0:1

edit the file ifcfg-eth0:1
change the DEVICE= line to be DEVICE=eth0:1
change IPADDR to your xx.xx.xx.27 address
setup your netmask if needed

then type this to enable it
ifup eth0:1
and to disable it
ifdown eth0:1
0
 
LVL 5

Accepted Solution

by:
mrielf earned 1000 total points
ID: 12720531
You can ping both ip from outside?

If yes, then check NameVirtualHost directives...





Listen 80

NameVirtualHost xx.xx.xx.26:80
NameVirtualHost xx.xx.xx.27:80

<VirtualHost xx.xx.xx.27:80>
    ServerAdmin jasonstarin@giant-head.com
    DocumentRoot /var/www/dotnet
    ServerName www.mysite.net
    ErrorLog /etc/httpd/dotnetlogs
</VirtualHost>
<VirtualHost xx.xx.xx.26:80>
    ServerAdmin me@mydomain.com
    DocumentRoot /var/www/html
    ServerName www.mysite.com
    ErrorLog /etc/httpd/dotcomlogs
</VirtualHost>
0
 
LVL 1

Author Comment

by:preserver3
ID: 12720593
You were absolutely right, but there was one more step I needed to do in Apache Server to make everything work.


NameVirtualHost xx.xx.xx.26:80
<VirtualHost xx.xx.xx.26:80>
    ServerAdmin me@mydomain.com
    DocumentRoot /var/www/html
    ServerName www.mysite.com
    ErrorLog /etc/httpd/dotcomlogs
</VirtualHost>
NameVirtualHost xx.xx.xx.27
<VirtualHost xx.xx.xx.27:80>
    ServerAdmin jasonstarin@giant-head.com
    DocumentRoot /var/www/dotnet
    ServerName www.mysite.net
    ErrorLog /etc/httpd/dotnetlogs
</VirtualHost>


My distro is Fedora Core 2, and I was able to use the network configuration tool tocopy the xx.xx.xx.26 at eth0 and make a copy that I then edited and changed to the .27 suffix.

I'm giving you all of the points, but this is needed to finish the rest of the question
0
 
LVL 1

Author Comment

by:preserver3
ID: 12720603
Well, Mreilf answered while I was repsonding.  I'll split it between you two.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you are running a LAMP infrastructure, this little code snippet is very helpful if you are serving lots of HTML, JavaScript and CSS-related information. The mod_deflate module, which is part of the Apache 2.2 application, provides the DEFLATE…
If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Loops Section Overview
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question