Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Can I run two Apache servers off one IP?

Can I run two Apache servers off one IP?
Thread Tools
l008com
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 29, 2003, 12:26 AM
 
I don't mean virtual hosts either, I already run 4 web sites off one Server that way, and it works awesome. What I wanna do is break one of those sites off so it is its own machine. But I still need my Server to somehow forward requests for it to the other web server, which is going to have an internal IP address only. I know I could set up a tiny page on my main server that would forward to another port, which I could map to my other server, but I'd like to have a way to seemlessly connect it, so this domain would truley be hosted off the other server. Possible?
     
awaspaas
Mac Elite
Join Date: Apr 2001
Location: Minneapolis, MN
Status: Offline
Reply With Quote
May 29, 2003, 12:33 AM
 
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 29, 2003, 01:09 AM
 
How so?
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
May 29, 2003, 01:18 AM
 
Not sure if this is what you mean, but try this in your httpd.conf file:

Redirect /alias http://other.server.com

Or maybe this:

ProxyPass /alias http://other.server.com

Or

ProxyPassRevers /alias http://other.server.com

Is one of these what you are after?

(You need to have the mod_proxy Apache module for the last two to work)
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 29, 2003, 01:21 AM
 
No the other server is behind my router, it only has an internal IP adress, you can't access it from the outside world, so Apache would have to do some of its own rerouting to direct you from my main server to the "co" server.
     
geekwagon
Senior User
Join Date: Dec 2002
Location: Portland, OR
Status: Offline
Reply With Quote
May 29, 2003, 03:20 AM
 
What you are looking for is a reverse (acceleration) proxy. You could run Squid in reverse proxy mode on your external machine and have it proxy the connections to the inside machine. I do this for a bunch of servers at work (I'm admin an internet facing datacenter.) It works great and Squid is solid as a rock.

It will have to be bound to a different port or IP than your Apache is currently running on though. The previous post mentions mod_proxy, I haven't used that, it might do something similar..
     
seb2
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status: Offline
Reply With Quote
May 29, 2003, 06:13 AM
 
You might also want to have a look at Pound: http://www.apsis.ch/pound/ -- we use it at my university (in fact, I administer Pound and the Apaches), runs nicely.
     
moki
Ambrosia - el Presidente
Join Date: Sep 2000
Location: Rochester, NY
Status: Offline
Reply With Quote
May 29, 2003, 08:43 AM
 
Originally posted by l008com:
No the other server is behind my router, it only has an internal IP adress, you can't access it from the outside world, so Apache would have to do some of its own rerouting to direct you from my main server to the "co" server.
I believe this would work:

Have your main (external) web server forward requests to your web site's domain to your router, on a special port (such as 8080) and then set up your router to portmap to your machine that sits behind it.
Andrew Welch / el Presidente / Ambrosia Software, Inc.
     
absmiths
Mac Elite
Join Date: Sep 2000
Location: Edmond, OK USA
Status: Offline
Reply With Quote
May 29, 2003, 10:52 AM
 
Originally posted by moki:
I believe this would work:

Have your main (external) web server forward requests to your web site's domain to your router, on a special port (such as 8080) and then set up your router to portmap to your machine that sits behind it.
I was going to mention something similar - we use our firewall to route traffic to different machines based on virtual IP's. It actually works very well and saves a lot of maintenance headache on the web servers (not to mention that any downtime on one server does not affect any other sites) in exchange for a little maintenance on the firewall.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
May 29, 2003, 02:38 PM
 
Originally posted by moki:
I believe this would work:

Have your main (external) web server forward requests to your web site's domain to your router, on a special port (such as 8080) and then set up your router to portmap to your machine that sits behind it.
Well yeah thats basically what i suggested in teh begining, but it'd be nice to be able to do it without having my site forward you to mysite.com:someoddportnumber
     
Brass
Professional Poster
Join Date: Nov 2000
Location: Tasmania, Australia
Status: Offline
Reply With Quote
May 29, 2003, 09:29 PM
 
Originally posted by l008com:
No the other server is behind my router, it only has an internal IP adress, you can't access it from the outside world, so Apache would have to do some of its own rerouting to direct you from my main server to the "co" server.
As I said, isn't this what Apache's mod_proxy PassProxy / PassProxyReverse do?

See the documentation at:

ProxyPass & ProxyPassReverse
     
hyteckit
Addicted to MacNN
Join Date: May 2001
Status: Offline
Reply With Quote
May 31, 2003, 09:41 PM
 
The answer is Yes.

DNS server.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jun 1, 2003, 12:25 AM
 
Originally posted by hyteckit:
The answer is Yes.

DNS server.
Wow what a great reply, thats answers all my questions, what more would I ever need to know with all that info.
     
iJed
Dedicated MacNNer
Join Date: May 2001
Location: Edinburgh, UK
Status: Offline
Reply With Quote
Jun 1, 2003, 12:51 PM
 
You will have to run one of these servers on a different port. Only one task can be bound to a single port at once. Other than changing the port you need to do nothing else. I am however not sure how you change the port Apache runs on. The line

Port <port num>

in httpd.conf should do this. I am unsure how you would make your two instances of Apache to load httpd.conf files from different locations. Can this be done? If it can't I'm sure that there are some other web servers out there that support this. I wrote a simple multithreaded web server in Java a little while back that could do this.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jun 1, 2003, 01:01 PM
 
Changing the port is easy you on't need two copies of apache you can just do it within the virtual hosts. But I want two different machines, not just two different site, I already have 4 different sites.
     
iJed
Dedicated MacNNer
Join Date: May 2001
Location: Edinburgh, UK
Status: Offline
Reply With Quote
Jun 1, 2003, 01:19 PM
 
Originally posted by l008com:
Changing the port is easy you on't need two copies of apache you can just do it within the virtual hosts. But I want two different machines, not just two different site, I already have 4 different sites.
That teaches me to not read the posts properly before replying...

Anyway someone mentioned you can do this with a DNS server. Well the most commonly used unix DNS server is the Berkeley Internet Name Domain or BIND. You should be able to easily find this with Google. Sorry I can't be of anymore help than that.
     
l008com  (op)
Addicted to MacNN
Join Date: Jan 2000
Location: Stoneham, MA, USA
Status: Offline
Reply With Quote
Jun 1, 2003, 01:22 PM
 
Yeah I'm running OS X Server on my server now, and its DNS server IS running, for other reasons. How does it help me do this though?

I think if I run it on another machine on another port, I think I may be able to use modrewrite to change the url at pages are requested, I just don't know how. I think that is as close as I'm goona get though.
     
ibookuser2
Mac Enthusiast
Join Date: Sep 2000
Location: Somewhere
Status: Offline
Reply With Quote
Jun 1, 2003, 03:45 PM
 
Okay, let me make sure I understand this correctly. You have one machine that is currently your webserver. It's visible to the entire world on a public static IP. You also have a machine on your internal network that you want to be visible to the entire world, but you only have one public IP. Right?

The cleanest way to do that is to use Apache's ProxyPassReverse. (do a search for it in Apache's documentation). What it does is takes a virtual domain or a directory and proxies it to another server. E.g.

Request from client for http://www.mydomain.com/secondserver/ --> connects to www.mydomain.com (your primary server) --> primary server connects to secondary server, fetches pages, and sends them back to client

So everything is still going through your primary server as a proxy, but the pages are hosted on the second server.

The only way to leave the primary server out of the equation altogether is to run the secondary server on a different port, but like you said, it's kind of annoying having the port number in the address.

What you want to use depends on why you're setting up a second server. If you want to take some of the load off of the primary server, proxying won't do you any good, since with proxying the primary server still has to do work to serve from the secondary server. So if you're trying to distribute load, proxying isn't the answer.

On the other hand, if you're just running the second server for the convenience of having stuff hosted on a separate machine, proxying can help you.

I hope that answered your question.
     
Rainy Day
Grizzled Veteran
Join Date: Nov 2001
Location: Oregon
Status: Offline
Reply With Quote
Jun 3, 2003, 02:05 AM
 
     
goose
Forum Regular
Join Date: Jan 2001
Status: Offline
Reply With Quote
Jun 3, 2003, 02:22 AM
 
It sounds like you want packet forwarding with a domain name instead of port number. So, if I'm understanding you, you want your external server to continue to serve the four sites off that one IP and the fifth site on that IP to be off your internal server?

I guess you'll have to check if Apache if it can redirect requests to a certain domain to another server. If that's possible, you can have it forward the requests to that certain domain to your internal server (you might have to set up port forwarding on your router). If Apache can't do that, you may need to configure some other sort of packet filtering/forwarding on your server to point to your internal server and not use Apache to do that.

Check http://www.apache.org for some documentation on Apache.

There's never enough when you have too little
     
   
 
Forum Links
Forum 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 On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 09:31 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,