LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2006, 12:04 PM   #1
ddzc
Member
 
Registered: Oct 2003
Location: T.O
Distribution: SunOS 10
Posts: 97

Rep: Reputation: 15
Running a 2nd Web server on the same I.P?


Anyone know if this is possible. For example: 1 web server (runs hmtl sites) is configured on a home ISP i.p address on the default port.

Is it possible to run a totally different web server using that same i.p address but possibly configuring the website to load on a specific port under that same i.p so it doesen't direct people to the site on the first server? Can this be done? If so, how do you configure the specified port and was port can be used for the www.
The DNS entires will be the same.

Thanks!
 
Old 09-23-2006, 05:09 PM   #2
BogusTrumper
Member
 
Registered: May 2006
Posts: 77

Rep: Reputation: 15
I'm assuming you mean, for example, that one server (machine A) would be running on 192.168.1.5:80, while an entirely different machine (B) would be serving up another webpage at 192.168.1.5:81. That should be possible using port forwarding. What would happen is that Machine A would automatically route any requests for data on port 81 over to Machine B. Or you could set up some other arbitrary way of doing this.

Here's a site that discusses doing this using iptables:

http://www.hackorama.com/network/portfwd.shtml

Sounds like it'd be a good starting point, at least.
 
Old 09-23-2006, 05:56 PM   #3
ddzc
Member
 
Registered: Oct 2003
Location: T.O
Distribution: SunOS 10
Posts: 97

Original Poster
Rep: Reputation: 15
yes you got the right idea. It looks like the ip tables is what I was looking for.

I can re-summarize what I want.

Lets say my cable modem gives me an ip of 66.66.66.66 and I have a mini network and router setup. The main pc with the modem attached to it is running 192.168.0.1. The first webserver is running off of that. So the 66.66.66.66 ip is resolving to www.firstwebserver.com. So the first web server resided off of the cable modem i.p.

I have another machine on the same LAN and I want to run another web server off it. So I obviosuly need to use that same 66.66.66.66 i.p but when someone accesses my website, I want it to re-direct to my site instead of the default server I have setup.

So I suppose setting up the i.p tables and forwarding will do the trick. I thought I maybe had to specify a port, so when someone types the the domain name of the site I want to build on the second server, it can redirect to my site instead of the default port which is running off the first server

I hope this is not confusing. I have a lot more research to do it, it may sound a bit noobish (if thats even a word)

Last edited by ddzc; 09-23-2006 at 05:58 PM.
 
Old 09-23-2006, 07:02 PM   #4
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
If you don't want to use different ports, I'd have though that apache (for instance) would be able to simple redirect a name based virtual host and/or redirects
 
Old 09-24-2006, 07:39 AM   #5
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
Quote:
Originally Posted by ddzc
I can re-summarize what I want.

Lets say my cable modem gives me an ip of
66.66.66.66/www.firstwebserver.com -->192.168.0.1. (first web server)

I have another machine on the same LAN and I want to run another web server off it. So I obviosuly need to use that same 66.66.66.66 i.p but when someone accesses my website, I want it to re-direct to my site instead of the default server I have setup.

I hope this is not confusing. I have a lot more research to do it, it may sound a bit noobish (if thats even a word)
Whenever someone will browse www.firstwebserver.com, it will automatically open 192.168.0.1:80 ( so we got to do nothing for tht)

For another webserver (hosted at suppose 192.168.0.2:80)
We got to run..
Code:
iptables -t nat -A PREROUTING -p tcp -d 192.168.0.1 --dport 81 -j DNAT --to 192.168.0.2:80
Thats it ! (i assume that 192.168.0.2 has 192.168.0.1 as its gateway)

Now whenever someone will browser www.firstwebserver.com:81, it will automatically be redirected to another webserver hosted at 192.168.0.2:80.

Regarding Nating you can refer to may tutorial for an easy refernce.. http://amitsharma.linuxbloggers.com/portforwarding.htm

--
Quote:
Originally Posted by ddzc
So I suppose setting up the i.p tables and forwarding will do the trick. I thought I maybe had to specify a port, so when someone types the the domain name of the site I want to build on the second server, it can redirect to my site instead of the default port which is running off the first server
I dont find any need of two domain names.. but if still you need them then probably you got to specify a different port like 81 or some else to catch these packets n forward over to another webserver.E.g. www.secondwebserver.com:81, as this will by default comes to your 66.66.66.66 only.
___________________
With best regards,
Amit..
--
Quote:
Originally Posted by Albert einstein
Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.
--
RSYNC tutorial : http://www.amitsharma.linuxbloggers.com/how_to_rsync.htm
FIND command tutorial : http://amitsharma.linuxbloggers.com/how_to_find.htm
Samba tutorial : http://www.amitsharma.linuxbloggers.com/how_to_samba.htm
Port forwarding tutorial: http://amitsharma.linuxbloggers.com/portforwarding.htm

Last edited by amitsharma_26; 09-24-2006 at 12:33 PM.
 
Old 09-24-2006, 11:37 AM   #6
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
As billymayday said, you must remember that www runs off urls, which are names.
You can add ports after the names, but getting someone to type it every time is not very reliable.

You have a domain name, eg mycompany.com and you can choose the third/fourth level names off that yourself, eg site1.mycompany.com site2.mycompany.com,
then make the default webserver redirect to the correct webserver.

The instructions are at http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
 
Old 09-24-2006, 12:23 PM   #7
ddzc
Member
 
Registered: Oct 2003
Location: T.O
Distribution: SunOS 10
Posts: 97

Original Poster
Rep: Reputation: 15
thanks a lot guys, you all understand exactly what im doing. I'm only doing this b/c my bro is running his own servers right off the router (192.168.0.1) so I don't want to touch any of his stuff and would rather run my own servers.

I have one quick question which I probably already know the answer of b/c you guys pretty much told me so. Is it possible at all for someone to type my site, like www.mywebserver.com and have it automatically configured to redirect off the 81 port instead of 80 without them typing the actual port #? It then obviously must hit my site, for eg 192.168.0.2.

Thanks
 
Old 09-24-2006, 12:27 PM   #8
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
Sure, like I said above, if the server name is different, you can send it anywhere..

eg www.mywebserver.com and mywebserver.com are different urls..
 
Old 09-24-2006, 12:58 PM   #9
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
Quote:
Originally Posted by peter_robb
Sure, like I said above, if the server name is different, you can send it anywhere..

eg www.mywebserver.com and mywebserver.com are different urls..
Peter..
If www.mywebserver.com binds to 66.66.66.66:80 then can www.anyurl.com be binded to 66.66.66.66:81 & if yes then at what level ?

Will it be done during the DNS query (interaction during name conversion) or at local ISP ?

Regards,
Amit..

p.s : Default
 
Old 09-24-2006, 01:08 PM   #10
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
That's done in httpd.conf in the first line of the VirtualHost stanza..

eg
Listen 81
NameVirtualHost *
<VirtualHost *:81>

Just remember that whatever you have to type for a url, including port numbers, is part of the virtualhost definition.
If you have :81 in the url, the server must listen on port 81
and the VirtualHost definition must include it too.
www.domain.com will go to port 80

VitualHosts are explained at http://www.tldp.org/HOWTO/Virtual-Services-HOWTO-8.html

Last edited by peter_robb; 09-24-2006 at 01:09 PM.
 
Old 09-24-2006, 01:14 PM   #11
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
Quote:
Originally Posted by peter_robb
That's done in httpd.conf in the first line of the VirtualHost stanza..

eg
Listen 81
NameVirtualHost *
<VirtualHost *:81>

Just remember that whatever you have to type for a url, including port numbers, is part of the virtualhost definition.
If you have :81 in the url, the server must listen on port 81
and the VirtualHost definition must include it too.
www.domain.com will go to port 80
Peter i am not talking about any virtual hosting & nor about a different port.

I am taking the case that i have registered a domain name with MY ISP or any other ISP, e.g. www.xyz.com, & now i want whenever my clients go & browse www.xyz.com[without any ports specified], they should come to my static ip but not at 80, at other port 81, is that possible ?

Can my/any ISP do that ? (if yes)
But will that be done at DNS server level, i think NO.
 
Old 09-24-2006, 01:27 PM   #12
peter_robb
Senior Member
 
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
No such luck..
There's nothing apart from dyndns.org that might even offer the possibility of forwarding to a different port..

Getting to a different server is what the www part of the domain name is for.
www is only one possible name for your webserver, it's just the most common name.
xyz.com is registered, www.xyz.com is your choice, so is www2.xyz.com
You make these changes yourself on your dns server, then the first webserver does a redirect to the correct one.

You could set up a proxy for incoming connections to do this if you don't want to play around with the first server's programming setup.. But apache does this very well too..
 
Old 09-24-2006, 02:19 PM   #13
amitsharma_26
Member
 
Registered: Sep 2005
Location: New delhi
Distribution: RHEL 3.0/4.0
Posts: 777

Rep: Reputation: 31
Quote:
Originally Posted by peter_robb
No such luck..
There's nothing apart from dyndns.org that might even offer the possibility of forwarding to a different port..
Yes, they do.
(I've just gone through dyndns.com)

@ddzc (orginal query poster)
I am not sure about every DNS service provider but yes with dyndns.com(this is the case if your clients sit outside your LAN or on internet), you can make a domain name to redirect over to your existing 66.66.66.66:<any-port> & further redirecting it onto any LAN ip<any-port> web server. Or even you can get a new domain-name to redirect over to your existing domain-name:<different-port>.

Detailed information regarding dyndns.com
http://www.dyndns.com/support/kb/arc..._requests.html
For other DNS providers, i suggest that you should ask your ISP/DNS provider for domain name to a different port redirection.

The above solution fits best if in case your clients are accessing you through internet. Otherwise a locally hosted DNS server can easily solve this out.
__________________
With best regards,
Amit..
--
Quote:
Originally Posted by Albert einstein
Imagination is more important than knowledge. Knowledge is limited. Imagination encircles the world.
--
RSYNC tutorial : http://www.amitsharma.linuxbloggers.com/how_to_rsync.htm
FIND command tutorial : http://amitsharma.linuxbloggers.com/how_to_find.htm
Samba tutorial : http://www.amitsharma.linuxbloggers.com/how_to_samba.htm
Port forwarding tutorial: http://amitsharma.linuxbloggers.com/portforwarding.htm
 
Old 09-24-2006, 02:35 PM   #14
ddzc
Member
 
Registered: Oct 2003
Location: T.O
Distribution: SunOS 10
Posts: 97

Original Poster
Rep: Reputation: 15
thanks so much for the help guys.
 
  


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
Is Web Server Running? Want Apache SBFree Linux - Newbie 6 03-28-2005 10:04 PM
Can't find running web server carlg Linux - General 0 10-13-2004 06:58 PM
running web server pcdebb Programming 3 09-09-2003 09:25 AM
so is a web server running Linux without X 4x faster than win2k server? Mr. Mojo Risin General 3 09-02-2003 07:41 PM
Running Two Web Sites On the same server Chijtska Linux - Networking 3 06-08-2002 11:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:38 AM.

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