Hosting Web-site from Home
From Software By Jeff
| Table of contents |
Firewall
First, it's critical that you can reach your intended PC from the Internet on TCP port 80. If you've got no firewall, then go buy one and configure it... If you've got a firewall, you need to be able to set up port forwarding to your PC. Usually you can do this by hitting your firewall from the LAN side with a web browser, log in, find the port forwarding (sometimes called virtual servers), and set port 80 to forward to your PCs IP, which I hope you can get. The PC should either have a reserved DHCP address, or a static one. Static is easier, especially if your firewall is giving out the DHCP since they don't usually allow reservations.
Web Server
Then, you need a web server on your machine. I recommend Apache on LINUX or Solaris almost always. If you're going to do nothing but Java stuff (e.g., servlet, JSP, Struts) and static pages and files, then go ahead and use just Tomcat. If you're stuck on Windows on this PC, you can use the Windows ports of those products, or Microsoft's IIS. IIS works, even the personal version included with XP. If you need specific help getting your web server set up, let me know.
Make sure the server is ready to receive requests and has at least a sample web page to serve. Use something simple if you don't have one ready.
<HTML><HEAD><TITLE>COMING SOON</TITLE></HEAD><BODY>
<TABLE WIDTH="100%" HEIGHT="100%">
<TR VALIGN="CENTER" ALIGN="CENTER"><TD>COMING SOON</TD></TR>
</TABLE></BODY></HTML>
Domain Registration
Visit ItsYourDomian.com (http://itsyourdomain.com) or some other registrar and register your domain name. If you can't get a domain name, then you need to either cooperate with someone else who has a domain (no, you cannot use this one) or just forget about this.
The registrar will ask for some fundamental information, like your name, address, phone, and billing information. More often than not they'll require a credit card to start, and many offer other than credit card payments for renewal.
When you've done this, you'll probably receive an "under construction" or "domain reserved" kind of page automatically, one that offers more web users to get their own domain name. Don't worry about anything they say about making web sites easy; you're going to have your own server, and whatever you set up with them will only get in the way.
DNS
You need to be able to find your machine by way of the Internet DNS. This is where the trickery comes in.
Visit Zone Edit (http://zoneedit.com). Sign up and create an account. It's free for the first five domains and/or until requests for your any domains break some pretty high threshold; like 200,000 requests a month. Then it's $11 per month for a "credit" to cover more bandwidth per domain. You don't need to pay in any given month unless you go over the limit. Don't use an e-mail address from the domain when you create your account, of course, or you'll run a risk of never getting your e-mail. Use Yahoo! (http://mail.yahoo.com) or GMail (http://gmail.com) or something; if you need a GMail invite, let me know.
You should have registered your domain name, so add that to your ZoneEdit account. They'll give you a pair of name servers that you'll have to put in your domain registration; update your registration. As soon as you do, the next time you visit a ZoneEdit page it'll let you know if you've done it right--do it right.
ZoneEdit Edit
Now make some quick edits to your ZoneEdit account. Add an address to your domain; I recommend putting your domain name, without a servername, with the IP 0.0.0.0. Make a CNAME/Alias for www to the same server name. It'll balk, wanting instead to make two addresses with the same IP address, but if you do do it that way you'll have to maintain two addresses if your IP changes.
Your initial domain should look something like:
IP Addresses: domain.tld = 0.0.0.0 Aliases: www.domain.tld => domain.tld Mail Forwarding: all mail => your@other.addy
By doing the forward as a CNAME and addressing the raw omain name you easily end up with http://domain and http://www.domain always pointing to the same place. The way ZoneEdit does it, where they both have the same IP requires you to later do the dynamic update twice; once with and once without the "www."
E-mail Notes
Make sure the e-mail forwarding points to the correct place to get your e-mail for the domain; it'll default to whatever you used to create the account. You can simply create a GMail account for each domain and set up that as the domain's mail forward. If anything happens to your domain, you can still get to the e-mail, which you may need to straighten out your problem. Then you get web-mail for your domain instantly, too.
You can reply from your domain using trickery with your e-mail client, by setting up a from address using the service or your client. With GMail, it's pretty easy using their on-line forms, and then you get and send mail from someplace where someone else worries about SPAM. Plus they have filtering so you can sort your mail by sender or recipient address or other things...I digress.
Mail Server
Of course, instead of using ZoneEdit's mail forwarding, you can run a mail server, but I don't recommend that for anyone without a strong sense of commitment; my server deals in tens of thousands of SPAM messages a month for only a few thousand delivered e-mails.
If you do have a mail server, make sure that port 25 is open on your firewall, that your server is configured to handle mail for your domain, and that you have at least anti-relay and anti-spam in place, if not anti-virus, too. If you're going to POP into your server, open port 110, too.
DNS Updates
TOnce ZoneEdit is configured, use this URL in a web browser from that PC:
http://USERNAME:PASSWORD@dynamic.zoneedit.com/auth/dynamic.html?host=DOMAINNAME
You would replace the upper-case bits with whatever you worked out with ZoneEdit. In the web browser you won't see anything, but if you look at the page source you'll see a one-line status. Usually it says "no changes required," but the first time it'll say something like "updated," and if your DHCP changes your IP, that'll update, too.
Check the ZoneEdit page and you should see the 0.0.0.0 for your domain name has changed to your real IP.
Note if you want to do this to more than one PC, you need to replace DOMAINNAME with HOST.DOMAINNAME, or subsequent requests will replace previous requests. You also don't want to use www.DOMAINNAME as you've got a CNAME in that place.
Confirm
You should now be able to get to your machine by the domain name. Open your favorite browser and put your domain name in the address bar. You should reach your web server (if it's running) or receive an error code.
If you've done that fairly recently (say within a day), then your machine may have the domain name cached and you'll see the old one, not the new one. Wait a while, purge your cache, or try from a different machine.
You should be able to get to your machine by your firewall IP, if not by name. If you can't do that either, then the web server's not up, the firewall's configured wrong, or your ISP is blocking the traffic. If your ISP blocks the traffic, then you can't do anything about it. You might try to find a port they don't block, but no one surfs by http://server:port/ by default, so your URL gets goofy from the get-go.
Regular DNS Updates
I run Solaris, so I run a cron job every two hours to make sure that DHCP changes to my firewall IP address don't loose traffic. Usually the same address from DHCP is maintained as long as the machine re-claims it before the lease expires; and they try half-way. For example, on my server I use this script:
/usr/local/bin/wget --http-user=USERNAME --http-passwd=PASSWORD \
-O /var/log/zoneedit.log \
http://dynamic.zoneedit.com/auth/dynamic.html?host=DOMAINNAME
Using the script, the file /var/log/zoneedit.log has the same one-line status as the browser displays. Update too often and ZoneEdit complains, but bi-hourly seems sufficient.
If you're on Windows you can do an AT command to schedule it, but unlike cron you have to make a new job for every hour of the day. Plus you have to download the Windows version of wget (http://www.gnu.org/software/wget/wget.html) or figure out a way to script Internet Explorer (or write a little Perl or Java app to do the query...).