Give automation to a static website


Back  | Example

What exactly is a static site?

Unless you have a programming language running on your server this will give origin to a static site.
Static doesn't mean that page must look static: javascript can add much dynamism to pages, by visual effects and also with a high degree of interaction (just think to games): anyway all this remains confined to user's computer and its browser cache with no practical way to store the results anywhere.

If you want your user to fill a form and save data somewhere for later use you'll need a dynamic page.
Web forms can be hosted to any static site (because in fact web forms are static for all effects) but web form must point (i.e. send the data) to a another page that can handle the incoming data. This page is the dynamic one (a.k.a actuator). And needs to be written in a scripting language supported by the server where it resides.

Today most sites are hosted on servers located at an external provider; this is the most efficient solution because it allows you to share the costs of running a server with hundreds of other customers, but at the same time severely limits the possibilities of manipulating the host machine and usually does not allow you to load and run software of your choice on the server - including scripting languages.

Some provider offers for an additional cost a choice of scripting languages (as PHP or Python) running on server, while some other offers Microsoft Office integration of some kind.
No matter what you choose, if you discover you need them at a later time you'll need to subscribe for the service and migrate your existing web site to the new server (and usually a new provider).
This can be a real annoyance if you purchased (as many do) both domain name and hosting at the same time, especially if all you need is to add very little automation like collecting data from web forms.

Fortunately no one requires you to have your web forms and theirs actuator pages on the same server.
This is in facts quite common: if you look at Google and its many services you'll notice that you are continuosly bounced from a server to another.
Why shouldn't you do the same?
Well: probably because you think not to have servers to bounce your pages to.
But this, in facts, is not necessarly true.

Using what you already have

Let's see exactly what we are shure you have at your disposal:

  1. You have a web server (i.e. a small portion of it) where creating the web forms: the one made available by provider.
  2. You have your own computer (probably the one you're using right now).
  3. You have the internet connection you're using in this moment to read this page.

As you see in point 1 and 2 in facts you have some computer available for bouncing. Of course being unable to to act on server you will need to act on your computer, but this shouldn't be a problem.

Problem could arise at point 3: probably your internet connection passes through a router. If you have full control of this router you're done: even if you're sharing the connection with co-workers you can instruct the device to route the incoming web forms to your own computer, making it the bouncing server running the actuator pages.
The only problem remained now is how to do all this.

One last hurdle to overcome

Now that we know to have two machine at our disposal we have the problem to make them aware of each other.
For what concerns the first machine (the remote server hosting the static pages) there is no problem: it is reachable by the domain name.

Things are different for the second (the local server, our automation machine), that probably is standing behind the router (and possibly a firewall) and is presenting to internet only an IP address shared among all other computers of your LAN.

All modern routers offers internal redirection capabilities (a.k.a Virtual Server feature) so addressing all (or specific) incoming requests to the local server shouldn't be a big deal (usually everything is managed by router trough a simple web interface).
The real problem is to know how to make the remote server reach the router (and thus the local server) trough internet.

The vast majority of ISP (internet service providers) offers ADSL with dynamic IP addresses: this practically means that you're assigned an IP that changes with the time, and that is assigned to you on a random basis. There is no way to know in advance what this IP will be and how long it will be leased to you.
Some company changes the IP any time you restart the router, others periodically re-assign addresses, others use a mix of different policies.

The fact is that if you need to reach your router (and thus you actuator server) you can't count to IP address, becasue this is subject to change and thus unreliable.
Fortunately this is a common problem and as such has already been addressed and solved by the internet community: since you have a dynamic address, then you need a dynamic DNS.

Dynamic DNS to reach your local server

A DNS (Domain Names System) actually converts intelligible names to numeric IP addresses, so you can type www.dbfree.org (the domain name) and reach the corresponding IP address where (supposedly) our web server waits for you for serving pages.

Basicly you register a domain name (by means of an authorized registrar) and once it is assigned to you steadily you have a record in a wordwide database where you will specify (among other things) the IP address you want to pair with it.
Practically anytime someone around the world types your domain name the DNS returns the IP address specified in the MX field of the correspondant DNS record.

If you know nothing about all this but your remote server and its web site are up and working it means that your ISP has done everything for you automatically, and you don't need to touch anything on that side.
Anyway on your side (the local server) there is no ISP to count on so you'll have to deal with this matter by your own, with an helping hand from www.no-ip.com

The trick of making your local server always reachable from internet from a ever-changing dynamic IP connection is done by updating your DNS record automatically whenever your IP address changes.
This can't be done with a standard DNS service (because of its inherent distributed mechanisms that take days to propagate and reflect the changes) but requires special DNS systems like those offerd by TZO.com, no-ip.com and others.

Basically all you have to do is:

Of course there are other requirements to fulffill;

Notice that many routers already offer a dynamic DNS feature that lets you use your No-IPaccount directly without need of installing anything on computer.

Routing requests to local server

Now that your dynamic IP is no more a problem it's time to set your router by using its Virtual server (or NAT) features.
The exact procedure depends by the router but basically should follow these guidelines:

In practice what you need to do is to make the router to respond on every request on its listening port 80 by routing all the corresponding traffic to port 80 of your local server (identified by its LAN IP address).

So, in our example, anytime the remote server will address a requests for server12324.sytes.net you local server will respond.

This example shows a web form residing on a static site (dbfree.org) and linked to another server via no-ip account (server1234.sytes.net):

Form residing on www.dbfree.org Actuator page residing on server1234.sytes.net

Your name
Type a number
Choose an operator
Type another number


         

This is the code for inserting the form above on your computer:

<form method="POST" action="http://server1234.sytes.net/index.msp" target="_blank">
  <p>Your name <input type="text" name="VAR_NAME"><br>
    Type a number
    <input type="text" name="VAR_VALUE1"><br>
    Choose an operator
    <select name="VAR_OP">
        <option>+</option>
        <option>-</option>
        <option>*</option>
        <option>/</option>
    </select>
  <br>Type another number
    <input type="text" name="VAR_VALUE2"><hr>
    <input type="submit" value="Do calculation">
    <input type="reset" value="Reset">
</form>

What is intended for automation?

At this point you're ready to add automation to your site.
How much automation depends from numberous factors.