Building Your Own Web Server

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 12

www.1000projects.

com
www.fullinterview.com
www.chetanasprojects.com

Building Your Own Web Server

Building Your
Web Server

really hard to push out media-rich pages,


but it took a long, long time to do so.
The second-generation "Webster" used
a faster 16-bit PIC processor with builtin Ethernet hardware also running the
Microchip TCPIP stack. But even with
an increased clock rate and word length,
this design also was quickly dismissed as
inadequate.
For third-generation he used a
NetBurner (NB) MOD5270 module
coupled with custom electronics, which
included a power supply and an SD card
interface. This design had all of the
features and performance he needed and
was used successfully for his website for
eight months. Unfortunately, this web
server was terminally damaged when he
tried to change out a part that had failed.
Knowing he had to build yet another
web server to replace the broken one and
being happy with the NB hardware, He
created the fourth generation Webster,
which he call "Webster2" because it is
the second of the designs published. In
this iteration, He did away with custom
hardware and based the design on the
NB MOD5270LC development kit. With
the stock NB hardware, building the web
server was a breeze.

Own

Abstract:
Building You Own Web Server is named
as "webser2" developed by Craig
A.Lindley is a degreed hardware
engineer. He decided to build a lowerpower web server for use in hosting our
personal website. If we use desktop PC
as host, but knew it consumed way more
energy(100
X
even
without
monitor).Webster require only 3.3 volts
and
250mA
low
power
operation.Webster2 is the fourth
generation web server designed and built
and fully capable of supporting all our
current web server needs. It has the
stability and performance necessary for
serving pictures, large documents,
music, and video files for our friend or
etc.
Evolution of Webster2:
If we use desktop PC as host, but knew it
consumed way more energy(100 X even
without
monitor).Craig
A.Lindley
decided to build a low web server for use
in hosting his personal website. So he
quest began with the design of a web
server based on a 20-MHz 8-bit PIC
microcontroller. The design consumed
little power, but wasn't fast enough to be
truly practical.
This first-generation "Webster" was
like the little engine that could. It tried

Webster2:
Besides the energy conservation issue,
Webster can be put on the Internet
without concern for viruses and spyware.
Webster's software is written entirely in
C++ with no underlying operating
system with exploitable security flaws.
Since, by design, there isn't any write
access to the underlying file system, it is
unlikely the website content can be
Page
1

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
compromised. Finally, since Webster
supports basic authentication, access to
the website can be controlled with a
username and password. Of course like
any web server, Webster2 could be
brought to its knees by a denial-ofservice attack.

containing a switching power supply,


an SD memory-card socket, a realtime clock chip, two RS-232 ports,
eight programmable LEDs, an 8position dip-switch, and a Reset
button.
Wall wort transformer for powering
the development board.
Cables including an RS-232 cable
and multiple Ethernet cables.
Eclipse-based C/C++ development
environment for writing, compiling,
and debugging code running on their
platforms. Included are numerous
example applications that you can
extract code from to get your designs
up and running quickly.

Building and maintaining a website with


Webster2 is easy. We can compose web
pages on our PC using the free nvu
HTML editor.When finished, the HTML
pages can be copied to an SD memory
card that is subsequently moved to the
server, or the pages can be FTPed to an
SD memory card already in place on the
server. When Webster2's Reset button is
pressed, the new or modified website
becomes immediately operational.
At the most basic level, any web server
is just a device that understands and
implements HTTP protocol; a web
server doesn't influence website content.
A web server's job is to stream requested
content to a user's browser, whether that
be HTML files, image files, PDF files,
MP3s, or whatever. This is important
because it is the content of the served up
files that may or may not be compatible
with different browsers. If the website
you serve with Webster2 works with
Internet Explorer but not Firefox, it
probably isn't Webster2's fault.

NetBurner's slogan is "Networking in 1


Day!" and it is absolutely true. They
provide code for support of most Internet
protocols,
making
application
development almost trivial. In addition,
they provide excellent customer support
and have a public forum of dedicated
developers that can and do help with
problems.
Protocols used in Webster2 Design:
There are a number of
networking protocols that come
into play in Webster2's design.
DHCP. Webster2 can use DHCP
to
obtain
its
networking
parameters (IP address, and so
forth) from a DHCP server on the
network to which it is attached. If
DHCP isn't used, the networking
parameters can be set statically
via entries in a configuration file.
DNS. DNS is like a phone book
for the Internet for turning host
names into IP addresses. DNS
entries must be in place so that

The NetBurner Development Kit:


The folks at NetBurner have put together
a great development kit for their
MOD5270 module. The kit includes
everything you need to develop and test
code including a:
Network-ready
MOD5270 core
computer module.
MOD-DEV-70 development board,
which the MOD5270 plugs into
Page
2

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
Webster2 can be found on the
Internet by name.
FTP.
Webster2's
software
includes an FTP server that lets
website content be stored on the
on-board SD memory card to be
updated remotely. Updates can
be made using FTP client
programs like FileZilla, or via the
publishing mechanism of your
web page design software.
HTTP. HTTP is the protocol of
the WorldWide Web. HTTP is
used between web browsers and
web servers for information
transfer.
NTP. Webster2's software uses
NTP (Network Time Protocol)
for keeping its system clock
accurate.
UDP. UDP (User Datagram
Protocol) can be used by
Webster2 to log web server
accesses to a remote computer.

must open up the firewall in the router to


allow inbound HTTP connections so
users outside your network can hit your
server. How this is done depends upon
our firewall. Keep in mind, in trying to
host a website on a home DSL
connection, the IP address assigned to
our DSL router changes from time to
time. This is a problem whether we are
using Webster2 as our web server or a
professional product like Apache.
Regardless of how we can access our
website, when our router's IP address
changes, connectivity to our website
using an old address will be lost. A
solution that lets you host a DSLconnected website is a program called
No-IP. No-IP (the company) offers a free
dynamic DNS and web redirection
service for just this purpose. No-IP will
even provide you the use of a domain
name from a list of preexisting domains
that we can use for free. The No-IP
client program runs as a service under
Windows XP. It continually monitors the
public address exposed by your router
for your web server and informs No-IP's
DNS servers of any changes. So as long
as access to your website is via your
chosen domain name, you are insulated
from changes to your router's IP address.
By running No-IP on any PC in your
network, access to your website is
maintained even if the public IP address
of your router/server changes. Once you
register your web server host with No-IP
and our server is operational, we should
be able to ping our server. We would
need to change the ping command to
check your server in your domain. Once
we have web content in place and we
can ping our server, we should be able to
access our website with a browser
(Internet Explorer, Firefox, or whatever)
by specifying a Universal Resource

Because Webster2 uses all of these


protocols, it may be necessary to
configure any firewall software you use.
Most importantly, you must allow HTTP
requests to pass through the firewall or
Webster2 won't be available on the
Internet. This feature is called "port
forwarding" in some cases.
Using Webster2 :

Before Webster2 can go online. you


must decide if static or dynamic IP
addressing is to be used. Using DHCP is
always easiest if your network permits it.
For our website, we can connect
Webster2 directly to our wireless DSL
router and use DHCP so the router
assigns an IP address automatically. This
works fine. Once your web server has a
public IP address, as mentioned, you
Page
3

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
Locator
or
URL
of
the
form:http://hostname.domainname

switch
I used a green
LED power Any brand
LED
for
on indicator LED
power on

Webster2 Hardware:

I used a red
LED access Any brand
LED as access
indicator
LED
indicator

Webster2 is based entirely on the NB


MOD5270LC
development
kit
hardware. As such, only two things are
required to get Webster2 running. First,
you need to insert an SD memory card
(64-GB max) into the socket on the
development board and second. While
packaging the NB hardware is not
required for its operation, he decided to
package the development hardware to
protect it from accidental abuse or
damage. At my local electronics shop, he
found a plastic box made by Serpac that
the hardware would easily fit into; see
the complete parts list in Table

Misc.
hardware

Screws, nuts
For mounting
and spacers,
NB module
etc.

Memory
Card

64 GB max; 1
SD memory
GB
usually
card
adequate

Because He was going to hide the


hardware inside the box, He thought it
necessary to mount important controls
and indicators on the outside. In the end,
He mounted a power switch, power
indicator, reset switch, and access
indicator on the box; see in Figures . The
packaging steps He took are as follows:

Designatio
Value
n

Notes

NB
developmen
t
kit
MOD5270 hardware.
LC
Part
#:
NNDKMOD5270L
C-KIT

Available
directly from
NetBurner,
Inc.

Box

Serpac
Model #271
See
or
#271-I
www.serpac.c
Dimensions:
om
7"x 4 3/4"x
1 3/4"

SPST
power
switch

Any brand I
used
a
off/on
miniature
switch
toggle switch

SPST
Any brand This is the
momentary pushbutton server's reset
contact
switch
switch
pushbutton
Page
4

1. Lay the NB module into the box


with the dip-switch facing the
front of the box to visualize how
things will fit.
2. Remove any of the box's molded
standoffs that are in the way
using a drill bit larger in diameter
than the standoff. The idea is that
the NB hardware should be
supported in the box by the
acrylic feet attached to the
bottom of the printed circuit
board (PCB).
3. With the PCB held in place, mark
the box with the position of two
or more of the mounting holes on
the NB PCB. Drill these holes for
#6 machine screws.
4. Layout the positions of the two
switches and the two LEDs on
the bottom front portion of the

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
box. Drill holes of the
appropriate sizes for mounting.
Glue the LEDs into place and
mount the switches.
5. File two holes in the top rear
portion of the box to allow the
power and network cables to
protrude.
6. Mount the NB PCB into the box
using appropriate screws. The
screw heads should be on the
outside of the box; nuts on the
inside. Tighten the screws but not
so tightly as to cause the PCB to
bend.
7. Carefully
unsolder
surfacemounted LEDs 8 and 9 from the
PCB. Unsolder and remove the
reset switch as well. Led8 is the
furthest right in the row of eight
LEDs. Led9 is located to the left
of the dip-switches. The reset
switch is located above the row
of eight LEDs.
8. Cut the connector off of the
supplied power cable. Pay
attention to the polarity of the
cable. There was a white strip on
the + side of the cable on the unit
I used. If you cannot tell which is
the + side of the cable. use a
multimeter to determine it.
9. You will probably have to extend
the power cable by soldering
other wires onto it. A six-inch
extension will probably do it.
Again. be careful of the polarity.
10. Solder the - end of the power
cable to the GND terminal on the
PCB. Solder the + end to one
side of the power switch.
11. Solder one side of another wire
to the other switch connection
and the other side to the
"7to18V" terminal on the PCB.

12. Determine the + side of the


power LED by holding the leads
to a 9V battery and noting which
orientation causes the LED to
light. Note which lead of the
LED is connected to the + side of
the battery.
13. Solder a wire from the + side of
the power LED to the +
connection on the PCB for Led9,
which was removed earlier.
Solder another wire from the
other lead of the LED to the
other connection for Led9.
14. If you are feeling lucky, plug in
the wall wort and turn the power
switch on, if all is well you
should see the power LED come
on. Turn power back off and
unplug the wall wort.
15. Solder two wires from the reset
switch to the two pads on the
PCB from which the reset switch
was removed. Polarity is not
important here.
16. Determine the + side of the
access LED as you did for the
power LED.
17. Solder a wire from the + side of
the access LED to the +
connection on the PCB for Led8,
which was removed earlier.
Solder another wire from the
other lead of the LED to the
other connection for Led8.
18. Connect an Ethernet cable to the
RJ-45
connector
on
the
MOD5270 module and route it
and the power supply cable out
of the box.
19. Place the top on the box and
screw it to the bottom using the
screws provided.
That's it with the hardware. Plug
Webster2's power cable in and plug the
Page
5

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
network cable into a network port. Flip
the power switch to on and you are ready
to go.

Webster2 Diagrams:

Figure 2: The finished Webster2 Web


Server From the left are the power
switch, the green LED power on
indicator, the pushbutton reset switch,
and the red access LED. Holes are filed
in the rear of the chassis for power
supply and network cables to pass
through.
Webster2's Software
You will need some of the tools provided
by NB on the CD that comes with the
development kit to download the web
server software to your server. Install the
development kit on your computer. Also,
get the ZIP file containing the Webster2
code from the DDJ website . First, it is
necessary to verify your server is
running and available via the network.
The easiest way to do this is to bring up
the NB IPSetup program. If all is well
you should see a MOD5270 device listed
in the right pane and see the networking
parameters your server has adopted in
the left. If you don't see your server,
make sure the server is plugged in, the

Figure1: Inside the Webster2 chassis

Page
6

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
power switch on, power indicator lit, and
the network port you plugged into is
active. Once you can see your server,
bring up the NB AutoUpdate tool. The
IP address you saw in the IPSetup
program should again be displayed.
Click the Browse button and navigate to
the directory you unzipped the Webster2
code
into.
Find
the
file
Webster2_APP.s19 in the release
directory. Click the Update button and
the web server code will be transferred
to your server. Before Webster2 can be
used it must be configured. Webster's
operation is controlled by the config2.dat
configuration file that must reside in the
root directory of the server's flash drive.
Webster will blink all eight on-board
LEDs and halt operation if the
configuration file is not found, or if an
error is detected in its format. Example 1
is a typical configuration file. The
configuration file is a human-readable
text file with each line terminated by
carriage-return, linefeed characters. The
code (in config.cpp) that parses this file
is not very forgiving so it is important to
not deviate from the format shown. Most
entries in the configuration file are
probably self-explanatory

Username: roy
Password: rogers
Pages
Requiring
Authentication:
page1.html,page2.html,page3html
//
Use FTP Security: no
FTPUsername: rogers
FTPPassword: roy
//
Use NTP: yes
NTP
Servers:
207.200.81.113,164.67.62.194
Time Zone: -6
Use DST: yes//
// Static IP Addresses - Only necessary if
not using DHCP
//
Static IP Address: 192.168.0.32
Static Subnet Mask: 255.255.255.0
Static Gateway Address: 192.168.0.1
Static DNS Address: 205.171.3.65
//
// Use UDP Logging
//
Use Logging: yes
Logging Hostname: your logging
hostname
If Use Logging is "yes" and Logging
Hostname is specified, UDP packets are
sent the specific host. If Use Logging is
"yes" and no Logging Hostname is
specified, UDP packets with logging
information are broadcast. You have two
ways to make configuration changes:
You can remove the SD memory card
from the server and connect it to your
computer via an SD card reader and
make changes to the config2.dat file
directly; or you can edit a local copy of
config2.dat and use FTP to update the
server's configuration. Either way, once
the configuration changes have been
made and the Reset button hit, Webster2
should come back up with the new

// Webster2 Configuration File - Version:


1.1
// NOTES:
// 1. Case is significant
// 2. No blank lines allowed; Use // for
comment lines and formatting
//
3. Be careful with spaces around
usernames and passwords
// 4. Don't use tabs
//
Realm Name: Your website's Name
Hostname: YourHostname
Use DHCP: yes
//
Use Authentication: no
Page
7

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
configuration operational.Once you have
determined
your
configuration
requirements and have them coded in the
config2.dat file, you can start working
on your website's content. Remember,
you should have a file in the root
directory named index.html or index.htm
as this will be the entry point for your
website. Other than the index file, how
you arrange your HTML files and other
website content is up to you. You have a
full FAT filesystem on your web server
so filename case is important and long
filenames are permitted. Also, you can
organize your files into subdirectories if
that fits your style. In this iteration of the
web server software, He wanted to have
some form of logging so He could see
when and by whom my website was
accessed. My first inclination was to use
a log file in the filesystem, but He
rejected this approach as flash memory
has a large but finite number of write
cycles. Writing to a log file for every
website access could damage the flash
over time. Instead, He decided to log
across the network to another machine.
He used NB's SysLog function in the
web server code and NB's UDP Terminal
Tool on the remote machine to see all
accesses to my website. It is pretty cool.
System logging uses UDP port
514.Within the GET processing code in
the web server, He turn Webster2's
access LED off/on. This causes the LED
to flash whenever his website is
accessed. Finally, if you want to modify
and/or extend the Webster2's web server
software He provide, you need to create
a new project within the Eclipse
development environment and import all
of my code. With this as the starting
point, you can make all of the changes
you desire.

Webster2's features include:

Low-power operation. Only 250


mA is required at 3.3 volts, or
about 0.8 watts.

Small size. The packaged web


server is about the size of a
hardbound book.

100 baseT Ethernet connectivity.

Support for static and dynamic IP


address assignment.

Based upon a 32-bit ColdFire


processor running at 147 MHz.

Support for basic authentication


for website access control.

A built-in SD memory card


interface (up to 64 GB max) for
web page file storage.

A built-in FTP server allowing


for in place update of website
content.

Conclusion:
Webster2 was fun and easy to build and
helps me conserve energy. Webster2 is
the fourth-generation web server I have
designed and built and is fully capable of
supporting all my current web server
needs. It has the stability and
performance necessary for serving
pictures, large documents, music, and
video files for my family and friends.
Webster2 costs about $130 to build, but
you will have the satisfaction of
knowing you did it yourself. That can

Features of Webster2::
Page
8

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com
earn you some serious bragging rights
with your high-tech buddies.
References:

www.ddj.com

Dr.Dobb's Journals

List of the important


popular web
servers of the
world.

Apache web server - the


HTTP web server

Free and the most popular


web server in the world developed by the
Apache Software Foundation. Apache web
server is an open source software and can
be installed and made to work on almost
all operating systems including Linux, Unix,
Windows, FreeBSD, Mac OS X and more.
About 60% of the web server machines run
the Apache web server - Refer Web server
usage statistics from Netcraft.
Apache Web Server
Install Apache web server on Windows 7:
How to instructions with screenshots

Page
9

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com

Apache Tomcat

architecture which uses small and


predictable amounts of memory under
load.
Nginx web server

lighttpd
The Apache Tomcat has
been developed to support servlets and
JSP scripts. Though it can serve as a
standalone server, Tomcat is generally used
along with the popular Apache HTTP web
server or any other web server. Apache
Tomcat is free and open source and can
run on different operating systems like
Linux, Unix, Windows, Mac OS X, Free
BSD.
Apache Tomcat

lighttpd, pronounced "lighty"


(don't ask me why), is a free web server
distributed with the FreeBSD operating
system. This open source web server is
fast, secure and consumes much less CPU
power. Lighttpd can also run on Windows,
Mac OS X, Linux and Solaris operating
systems.
lighttpd web server

Microsoft's Internet
Information Services
(IIS) Windows Server

Jigsaw

IIS Windows Web Server has


been developed by the software giant,
Microsoft. It offers higher levels of
performance and security than its
predecessors. It also comes with a good
support from the company and is the
second most popular server on the web.
Microsoft IIS Windows Web Server

Jigsaw (W3C's Server)


comes from the World Wide Web
Consortium. It is open source and free and
can run on various platforms like Linux,
Unix, Windows, Mac OS X Free BSD etc.
Jigsaw has been written in Java and can
run CGI scripts and PHP programs.
The Jigsaw web server software from W3C

Nginx web server

Klone

Free open source popular


web server including IMAP/POP3 proxy
server. Hosting about 7.5% of all domains
worldwide, Nginx is known for its high
performance, stability, simple configuration
and low resource usage. This web server
doesn't use threads to handle requests
rather a much more scalable event-driven

Klone, from KoanLogic Srl,


includes a web server and an SDK for
creating static and dynamic web sites. It is
a web application development framework
especially for embedded systems and
appliances. No additional components are

Page
10

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com

X5 (Xitami) web server

required when using Klone; thus, one can


do away with an HTTP/S server or the
active pages engine (PHP, Perl, ASP).
Klone web server

Abyss web server


The cross-platform X5 from
iMatrix Corporation is the latest generation
web server using the company's own
multithreading technology (Base2) that
makes it scalable to multi cores. As per the
iMatrix, X5 can handle thousands of
connections without difficulty and thus is
useful for long polling in which connections
from clients remain open for extended
durations.
X5 (formerly Xitami) web server

Abyss compact web server


runs on all popular platforms - Windows,
Mac OS X, Linux and FreeBSD. The
personal edition is (X1) 100% free while
the professional Abyss Web Server X2 has
a small price tag of $60. Supports
HTTP/1.1, secure connections,
CGI/FastCGI, custom error pages,
password protection and much more. The
server also has an automatic antihacking
system and a multiligual remote web
management interface.
Abyss web server

Zeus web server

The Zeus web server runs on


Linux and Free BSD operating systems
among others. It has been developed by
Zeus technology Ltd. And is known for its
speed, reliability, security and flexibility.
The web server is used on some of the
busiest web sites of the world including
Ebay. Zeus web server is not free and costs
more than a thousand pounds.
Zeus Technology Ltd. - Zeus web server

Oracle Web Tier

Includes two web server


options with reverse proxy and caching
solutions that lead to quick serving of web
pages and easy handling of even the most
demanding http traffic. The iPlanet Web
Server, for example, is a high-performance
server with enhanced security and
mutithreaded architechture that scales well
on modern 64-bit multiprocessors.
Oracle Web Tier

Page
11

www.1000projects.com
www.fullinterview.com
www.chetanasprojects.com

Page
12

You might also like