LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-20-2010, 03:27 PM   #1
firehak
LQ Newbie
 
Registered: Dec 2009
Location: North Canton, OH
Distribution: Fedora
Posts: 13

Rep: Reputation: 0
Best way to host 2 public servers from 1 external IP


I'm in the process of installing two virtual servers (Turnkey LAMP and Redmine appliances) and am wondering the best way to go about making both accessible through 1 external IP address. Is it possible to have both accessible from port 80 and redirect to the correct server? Or do I need to change the listening port for my repository?

I'm very frustrated with my web host and want to move my website to my own server until I can find/afford a suitable replacement, and my older brother and I need to have a private, internet accessible repository soon. I know changing the port is the most obvious solution, but we'd like to keep from having type specific ports if we don't need to.

EDIT: If anyone needs an example, I have both servers online. I have my lamp server in my routers port forwarding listed first, and so it seems to take over.

Current addresses:
http://www.animepwn.net - should point to a page that just says "www.animepwn.net" for now

http://lamp.stephansimon.net - should show the default webmin page

http://repo.stephansimon.net - loads webmin page instead.

Here are screens of my virtual host setup.
http://stephansimon.net/repo.png
http://stephansimon.net/lamp.png

I can also add the actual virtual host file contents if needed.

Last edited by firehak; 12-20-2010 at 09:36 PM. Reason: added example
 
Old 12-20-2010, 03:52 PM   #2
Noway2
Senior Member
 
Registered: Jul 2007
Distribution: Gentoo
Posts: 2,125

Rep: Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781Reputation: 781
If you are only hosting regular (http) web pages, Apache (LAMP) will support multiple of what are called virtual hosts on one IP address. The connection is established based upon the host name, eg site1.domain.com and site2.domain.com. I am not familiar with Redmine Appliances. If it also works on port 80, along with Apache, you may have some difficulties. If it works on a different port you will be fine.
 
Old 12-20-2010, 04:03 PM   #3
firehak
LQ Newbie
 
Registered: Dec 2009
Location: North Canton, OH
Distribution: Fedora
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you for the quick reply, but I already know about and use virtual hosts for Apache. These are 2 separate servers. I have my LAMP stack to host my 2 domains, and then I want my separate Redmine installation to be on a sub domain without having to type repo.stephansimon.net:8080 if possible.
 
Old 12-20-2010, 10:04 PM   #4
firehak
LQ Newbie
 
Registered: Dec 2009
Location: North Canton, OH
Distribution: Fedora
Posts: 13

Original Poster
Rep: Reputation: 0
I read up on mod_proxy and still couldn't figure it out, so I've done it the easy way. I forwarded port 8080 to 80 for my repository server, and the lamp server has 2 virtual hosts to take control over the sub domain. The lamp server has 2 PHP files that just redirect with the header() function to right port. I would have liked to keep from showing ports in the URL, but.. this works too, I suppose. Marking solved.
 
Old 12-22-2010, 06:26 AM   #5
beowulfnode
Member
 
Registered: Jun 2007
Distribution: debian, ubuntu, centos, esxi
Posts: 39

Rep: Reputation: 4
Quote:
Originally Posted by firehak View Post
I read up on mod_proxy and still couldn't figure it out
you can have 2 separate web servers on 1 WAN IP using a "reverse proxy" both apache and squid can do this. By the sounds of it you've had a go with apache, perhaps try squid.

I've just set up a squid reverse proxy on the recomendation of some of the linux guys at work using a page from http://wiki.squid-cache.org/ConfigExamples such as this

The way I did it was with 3 servers, all virtual, to simplify the config on each server. You could probably keep it fairly simple with having squid on one of the servers but on a separate nic ip. A few key points for the setup are
  • The Wan IP port 80 forward to squid lan ip port 80
  • which forwards to apache servers port 80
  • squid machine resolves domain names to the lan ip addresses, set this in squid machine hosts file if your dns config doesn't allow this easy enough
some key squid.conf points are
  • http_port 80 vhost
  • change "http_access deny all" to "http_access allow all"
  • cache_peer lan.ip.of.server1 parent 80 0 no-query originserver name=server_1
  • cache_peer_domain server_1 www.example.com example.com
  • cache_peer lan.ip.of.server2 parent 80 0 no-query originserver name=server_2
  • cache_peer_domain server_2 download.example.com alias2.example.net

a search around the net will often turn up config lines such as

httpd_accel_host virtual
httpd_accel_port 80 (the web server port)
httpd_accel_single_host off (It should be disabled when we are going to the reverse proxy for multiple servers)
httpd_accel_uses_host_header on

these are deprecated, but unfortunately show up in search results still
 
Old 12-23-2010, 12:11 AM   #6
firehak
LQ Newbie
 
Registered: Dec 2009
Location: North Canton, OH
Distribution: Fedora
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you very much, beowulfnode! Something like that is EXACTLY what I was looking for! Both of my virtual servers were both Turnkey appliances using Apache like you guessed, but I was just trying the apache proxy modules. I've heard of the squid proxy before, but I didn't know it could be used as a reverse proxy. And, thanks for taking a peek even though my thread was marked as solved. I hate just using quick and dirty work arounds. I have no idea how long it will be before I decide to purchase web hosting again and I didn't like the idea of combining my repository server with my lamp stack just to avoid using port numbers in the URL.
 
  


Reply

Tags
http, port, redirection


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
How-to secure public servers sucram2g Linux - Security 6 02-08-2007 09:15 AM
help with 1 public ip + two servers?? slackamp Slackware 2 04-06-2006 02:29 PM
public distcc servers? levicc00123 Linux - General 1 03-14-2005 11:27 AM
public apache servers TheHunted Linux - Software 6 03-17-2004 10:38 AM
Public NFS Servers fat_mike Linux - General 2 03-27-2003 09:06 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 05:24 PM.

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