Hosted By

Contact Me

Misc Links

OpenNTF BlogSphere LotusGeek CoComment Custom Button

Ads by Google

Welcome to keithstric.com!

I hope you find this site useful in some way or another. I strive to bring you all sorts of geeky information and solutions to your most frustrating of issues with the occasional rant on whatever topic, technical reviews and weblog. You'll also find many products that I've developed and make available for you to use however you like. So, grab a cup of coffee, sit down and visit for a while.

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

Summary

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:

  • Linksys DSL Router / 4-Port Switch / Wireless Access Point (AP) (Linksys BEFW11S4)
  • Web Server running whatever (Apache, IIS, Domino, etc.)
  • 2 Network cards in your Web Server (1 which is trusted and the IP Address is assigned via DHCP and the other with a static IP Address) - This actually isn't a requirement but is preferred.

  • 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:

  • Open your browser
  • Type in this URL http://192.168.1.1
  • Enter your password (Default is "Admin")
  • Click the "Advanced" button in the top right corner (See Figure 1)
  • Click the "Forwarding" tab (See Figure 2)
  • Under Ext. Port, Enter the relevant Port Numbers (HTTP = 80, SMTP = 25, FTP = 21, Lotus Notes = 1352, Telnet = 23, etc.) 1 per line (See Figure 3)
  • Under Protocol Select TCP or UDP or both, whichever is relevant (For HTTP just check TCP) (See Figure 3)
  • Under IP Address, Enter the IP Address of the network card with the static IP address (192.168.1.xxx) (See Figure 3)
  • Under Enabled, Click the checkbox next to each port listing to enable the forward (See Figure 3)
  • Click Apply

  • 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

    ID: 1
    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!

    ID: 2
    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.


    ID: 3
    Date: 02/07/2010 05:04:05 AM
    Name: null
    Website: http://null

    Emoticon Emoticon Emoticon Emoticon Emoticon

    Post A Comment

    :-D:-o:-p:-(:-):-\:-|:angry::cool::cry::dontknow::emb::hairout::laugh::rolleyes::whew:;-)

    Subscribe to keithstric.com

    OpenNTF

    Disclaimer

    The opinions and ideas posted on keithstric.com are not necessarily the opinions and ideas of my employer. The solutions, techniques and code provided here are not guaranteed or warranted in any way and are free for you to use at your own risk.