LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-19-2012, 05:30 AM   #1
Gelanin
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Rep: Reputation: Disabled
Multiple webservers on port 80 behind 1 external IP - possible ?


Hardware / Software:
1 Netgear wireless router running OpenWRT version 10.03.1, connected to internet.
3 different boxes running web services, 1 Windows Home server box, 1 linux and 1 Openindiana, connected to the wireless router through the switch-ports on the wireless router.

The OpenWRT box has the internal IP if 10.1.1.1

The OpenWRT box also has a small internal website for the web-gui for OpenWRT running on lighttpd on port 80.

Scenario / Goal:

Keep the small internal website with the web-gui running on port 80 accessible only from the inside of the OpenWRT box.

And "redirect" Multiple domain names that are all pointing to the same 1 dynamic IP allocated to my wireless router, to different internal servers on the inside of the OpenWRT box, while all of them are accessible on standard port 80

example.homeserver.com
example.dnsalias.org
www.example.com
www.example.net

What i would like to be able to do is a simple configuration that inspects the http header and sends the http-request to the correct server based on something like the following.(Either all domain-names specified, or some specified and all others sent to the same place to be handled with vhost on that server.

example.homeserver.com --> 10.1.1.10 (IIS)
example.dnsalias.org --> 10.1.1.20 (Apache)
www.example.com--> 10.1.1.30 (Apache set up with vhost)
www.example.net--> 10.1.1.30 (Apache set up with vhost)

or
example.homeserver.com --> 10.1.1.10 (IIS)
example.dnsalias.org --> 10.1.1.20 (Apache)
* --> 10.1.1.30 (Apache set up with vhost)

So, i guess the question is, is this even possible to accomplish ? And what would be the easiest way to accomplish something like this ?
I'm guessing this would probably involve some sort of reverse-proxy setup or something similiar ?

So, anyone done this before and can give me some good ideas, or links to examples/documentation that explains how to do this ?

Last edited by Gelanin; 02-19-2012 at 05:33 AM.
 
Old 02-19-2012, 07:32 AM   #2
BjarniRunar
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Rep: Reputation: Disabled
Quote:
Originally Posted by Gelanin View Post
Hardware / Software:
Scenario / Goal:
What i would like to be able to do is a simple configuration that inspects the http header and sends the http-request to the correct server based on something like the following.(Either all domain-names specified, or some specified and all others sent to the same place to be handled with vhost on that server.
...

Quote:
Originally Posted by Gelanin View Post
I'm guessing this would probably involve some sort of reverse-proxy setup or something similiar ?

So, anyone done this before and can give me some good ideas, or links to examples/documentation that explains how to do this ?
Yes, this should be possible. Lighttpd can be configured for virtual-host based reverse proxying, you may simply be able to do that since it is already installed:

http://redmine.lighttpd.net/projects...od_proxy-proxy

Another alternative (which I am the author of), is PageKite (www.pagekite.org). PageKite is software that bypasses your router entirely, creating a tunnel from your web server to an "in the cloud" reverse-proxy. You can either run the in-the-cloud part yourself (if you have a server somewhere), or you can use the service provided by my tiny start-up.

PageKite has a few advantages, in that your IP address is not directly associated with the websites (so better privacy), the service provides out-of-the-box SSL encryption and you can even use it with a mobile device - so you can run a public web server on a laptop and whenever it has Internet connectivity the site will be live. It's also really easy to use, once you've installed the software it's literally a one-line command to make a new website publicly visible:

$ pagekite.py localhost:80 http://newserver-youraccount.pagekite.me/

Check it out and let me know what you think! :-)
 
Old 02-19-2012, 08:45 AM   #3
Gelanin
LQ Newbie
 
Registered: Feb 2012
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks BjarniRunar!

Preferrably i'd like to keep things on my own boxes, so if i can get Lighttpd to do what i want, that would be awesome.

I guess something like the following should in theory work then if i put it somewhere sensible in the Lighttpd config ?
Guess i'll try experimenting abit with it later :-)

$HTTP["host"] == "example.homeserver.com" {
proxy.balance = "fair"
proxy.server = ( "" => ( ( "host" => "10.0.0.10" ),

$HTTP["host"] == "example.dnsalias.org" {
proxy.balance = "fair"
proxy.server = ( "" => ( ( "host" => "10.0.0.20" ),

$HTTP["host"] == "www.example.com" {
proxy.balance = "fair"
proxy.server = ( "" => ( ( "host" => "10.0.0.30" ),

$HTTP["host"] == "www.example.net" {
proxy.balance = "fair"
proxy.server = ( "" => ( ( "host" => "10.0.0.30" ),
 
Old 02-19-2012, 09:24 AM   #4
BjarniRunar
LQ Newbie
 
Registered: Sep 2011
Posts: 3

Rep: Reputation: Disabled
Quote:
Originally Posted by Gelanin View Post
Thanks BjarniRunar!

Preferrably i'd like to keep things on my own boxes, so if i can get Lighttpd to do what i want, that would be awesome.

I guess something like the following should in theory work then if i put it somewhere sensible in the Lighttpd config ?
Guess i'll try experimenting abit with it later :-)
Should work, if the mod_proxy module is installed. I have a config which looks a bit like this (bits not pertaining to the proxy skipped):

Code:
server.modules = (
           "mod_rewrite",
           "mod_redirect",
           "mod_alias",
           "mod_access",
           "mod_proxy"
)
...
else $HTTP["host"] =~ "^www1.myserver.net" {
  proxy.balance = "hash"
  proxy.server  = ( "" => ( ( "host" => "127.0.0.1", "port" => 19089 ) ) )
}
...
I personally prefer PageKite to futzing around with configs like that (they are so inflexible), but it really depends what you're doing which is more appropriate. :-)
 
  


Reply



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 setup multiple SSL on name-based virtual host webservers? chanjay Linux - Server 5 09-21-2011 04:28 PM
iptables forward - multiple external to multiple internal astbis Linux - Networking 3 01-24-2008 04:27 PM
A quick question about ports & internal/external networks for webservers... jacksonscottsly Linux - Networking 2 07-10-2005 09:35 PM
multiple webservers one gateway? phonecian Linux - Networking 4 03-11-2005 11:10 AM
port 80, firewalls, and webservers glevine Linux - Networking 8 06-03-2004 11:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11: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