Running a Web Server behind a Linksys DSL Router
04/08/2007 11:51 AM By Keith Strickland
Running a Web Server behind a Linksys DSL Router
This document was created because of a need to move my web site behind my Linksys DSL Router / Switch / Wireless AP. This is really my preferred way to run my web server as the Router acts as a hardware firewall and negates the need for so many rules on my Web Server firewall (See Figure 4).
Background
Like I said above. This is the way I would prefer to run my web server. This way I only have to have minimal rules on the Web Server firewall. The Linksys Router takes care of all the rest. We are going to setup our router so that the needed ports to run a web server will be forwarded to our server. So, here is the hardware:
Router Setup
I'm going to assume you already have your router setup to access the Internet. So follow these instructions and you will be able to run your Web Server from behind the router by forwarding requests to specific ports to your web server.
Goto the router configuration page:
Server Setup
OK, now we have to find out the IP Address of our router so that we can update our DNS entry at easyDNS. This is actually very simple and only requires a script and a cron job be setup.
Create the below Script file and save it in /usr/local/bin. Of course if you're running a Windows box this script won't work.
#simple script used to update from behind a nat
#written by tomasz@pucky.ods.org
#modified by fincoop@five-speed.net
#!/bin/sh
USERNAME="Dynamic DNS Username"
PASSWORD="Dynamic DNS Password"
SENDHOST="yourdomain.com"
SERVICE="easydns"
LOG="/var/log/ez-dns.log"
rm -rf index.htm*
wget -q www.whatismyip.com
IP=$(less index.html | grep TITLE | cut -d" " -f4)
/sbin/clock >> $LOG
echo $IP >> $LOG
/usr/bin/ez-ipupdate -q -a $IP -N root@localhost -h $SENDHOST -S $SERVICE -u $USERNAME:$PASSWORD >> $LOG
Create a CRON job to run the above script every 15 min or whatever you decide
And that's it, you're done.
Figure 1:

Figure 2:

Figure 3:

Figure 4:

Check out these resources for settiing up your web server and getting everything working.
www.dslwebserver.com
www.easydns.com











Comments
Date: 11/17/2008 01:56:56 PM
Name: Alex
Website: http://ebeg.ca/gee
I already have a web server setup like you mention, but I'd like to have a second box with another web server on it behind the same router.
How to do that?
Thanks!
Date: 11/17/2008 02:08:07 PM
Name: Keith Strickland
Website: http://www.keithstric.com
Alex,
It really depends on what you're trying to accomplish. If you just want another website Apache can easily handle this. However, if you wish to run some other type of web services server that you can't run on the same box that you're running apache on you can do that too. However, they won't be able to share the same port. For example you're existing site would run on port 80 and the other server would serve up http requests on 8080 or some other port.
But Apache has a feature called "Proxy" and what this does is allow your server to forward requests to another server, get the response and display it back to the user which requested the other service. The user only sees the URL that you have listed. So, if someone wants www.yoursite.com they'll get your homepage. But if you're running say a domino server as your 2nd server you can setup a url of www.yoursite.com/domino and then setup a ProxyPass and ProxyPassReverse rule in httpd.conf. But, you can read more about that here { Link } .
Hope that helps.
Date: 02/07/2010 05:04:05 AM
Name: null
Website: http://null