Web Server

Overview

This module gives students hands-on experience installing and interacting with a web server. Students will install and start a web server, generate a simple HTML file, and use a client node to retrieve the file.

Setup Time: Varies
Tutorial Time: 15 minutes

Objectives

Upon completing this module you will:

  • Be able to install and start a web server
  • Be exposed to creating and editing files using a console editor
  • Be able to retrieve a file from the web server

Tutorial

A. Slice Creation and Instrumentation

This module assumes you have an active slice with two connected nodes and SSH terminals to both nodes. If you don't, follow the steps in the GENI Setup module and the Instrumentation module, then continue here.

B. Video

If you haven't already, watch the video above. It will walk you through the steps of the module.

C. Installing An HTTP Server

1. If not already done, use GENI Desktop to open an SSH terminal to the server node.

2. Install a web server by typing

 sudo apt-get update

 sudo apt-get -y install apache2 

"sudo" allows you to perform this action as root and apt-get is a package-management utility for this distributions of Linux. Once completed, you should see the "Starting web server apache2" message, which means a web server in default configuration is now running and bound to port 80 (the default HTTP port).

D. Create a message to retrieve

1. Still on the server, navigate to the http root directory by typing in the following command:

cd /var/www/html 

This is the default directory from which the web server will serve content.

2. Remove the existing default webpage by typing:

sudo rm index.html 

3. Now, use nano or vim to make a new index.html and type a message that will be retrieved later:

sudo nano index.html 

or

sudo vim index.html 

4. Type in any message that you wish to transmit from the server to the client; it need not be HTML.
nano: type the message and then press Ctrl-X to exit. When it asks "Save modified buffer?", press "y" and "enter" to use the same filename.
vim: press the ‘i’ key, then type the message. Once you’ve finished, hit escape (Esc) and then type ":wq" to save changes and quit.

E. Retrieve the message

1. If not already done, in GENI Desktop open an SSH terminal to the client node. We assume the IP addresses are as described in the GENI Setup module (client=10.1.1.1, server=10.1.1.2). If this is not the case, you will need to substitute the correct server IP address below.

2. In the client's SSH terminal, run the following command:

telnet 10.1.1.2 80 

The telnet command opens a TCP connection to the server machine on port 80, the port on which the HTTP server is listening.

3. With the connection established, type the following to send the server a request for the contents of index.html:

GET /index.html 

The server processes the request and replies with the contents of index.html. You should now see the message you placed in index.html, on the server, printed on the client's terminal.

Going Further - Assignment

1. Create your own correctly formatted HTML document in place of the message in index.html. Follow the same procedure as above to retrieve this document. For those completing this module for credit, submit a screenshot of the output on the client machine.

2. You’ve learned that HTTP has many different status codes. By modifying your requests made from the client machine, generate 4 different status responses from the server. For those completing this module for credit, submit the requests you made to generate each response along with an explanation of why each response was sent by the server.

Shutdown

Upon completion of the module please delete your slice's resources as described in the Shutdown module.