Build a Web Server

This is a work in progress that will be updated continuously, I’ll post to the blog when a major change is made. I’d love any feedback you have

The web is important, it’s in everyone’s lives. I don’t think enough people understand how it really works, how the bits are actually put together. This project will guide you through building a simple web server. It won’t be complete or production ready, but you can learn a bunch along the way.

This site will be useful to at least two groups of people. First are those who want a better understanding of how the web works. If you have only built web applications using a framework or set of libraries this will teach you what underpins those tools. It won’t replace those tools but you’ll be much better equipped to use them and possibly even contribute back!

The second group are programmers who are learning a new language. Once you’ve worked through the language’s introductory tutorial you’ll probably be looking for a project to try in that language. If this is your first programming language be warned that you’ll be digging into the documentation of that language and you’ll have to answer questions for yourself(with a significant helping hand from Google). This is an essential skill for a professional software developer and you should practice it.

This guide is language agnostic, we’ll talk about protocols and specifications instead of libraries. This means you’ll need to do a significant amount of research outside of this guide to complete the project, this is intentional. If you are trying to learn a new language this is a great way to become familiar with the docs of that language. The decision of what libraries above and beyond the standard lib of the language is up to you. I’d recommend you stay with the standard library where possible. You could easily gem install rails and get on with life, but that’s not the point of this guide.

The tools used in this guide will be linux specific, you can follow along on other operating systems by you may need to make some slight adjustments to the command arguments. Think of it as another learning opportunity :-)

I have a few hints for this project: it’s not a school assignment, it’s not a paid contract, and it’s not work for an employer, you are welcome to complete each segment in as much detail as you would like. No one is going to blame you if you don’t use the perfect solution to everything. You don’t even have to write unit tests if you don’t want to, you can build a QA suite more detailed that a jet liners if you’d like! Although if you’ve never used test driven development this would be a great project to give TDD a try. Just don’t pile to many new things on at once, you can always work through this project a second time learning something new.

I HEREBY GIVE YOU PERMISSION TO MAKE MISTAKES, explore, make questionable design choices, delete code, refactor everything, shave any yaks you want, whatever you want to do with your project is okay. Please, this is how we learn!

In each section I’ll try to include some googleable words to help you in the right direction if you get stuck. A lot of these will be of the format “{ your language } some term”, so I’ll use those brackets to signify that the search should be language specific.

All this being said, you probably don’t want to use this in a production setting. And until we have a detailed section on security you might not want to expose a home built server to the wider internet. These is probably not a focused attack on your personal project, but it’s possible. Most of the attacks on the web are scrapers looking for well known exploits(you’ll see lots of this in the logs if you have logging and the server is exposed to the internet). But until you have a solid understanding of common security vulnerabilities it’s probably best to keep the server isolated from the wider internet. A good place to start reading about security is the OWASP top ten

This is broken up into segments that should build on each other. Some people may be able to skim over the description and get right to the tasks. Others may take more time, and that’s fine. It doesn’t matter if this takes you an hour or a week, it’s your project to complete how you see fit.

Next - start the project