Date Assigned:Mm/Dd/Yyyy

Date Assigned:Mm/Dd/Yyyy

Page | 1

Web Server

Date Assigned:mm/dd/yyyy

Time Due:mm/dd/yyyy by hh:mm

Educational Objectives

This lab is designed for students to gain first-hand experience on apache web server basic and advanced configuration, and web server security.

Machines used for this lab

A Fedora 18 Linux VM with Apache weber server installed will be used for this lab.

Section 1Investigate Internet route characteristics

How do Internet routes look like? How to draw an Internet map? Have you ever wondered about these types of questions? Now we have a chance to answer them.

In this assignment you will perform some experiments using a tool called pcharto study Internet routes and draw a simple Internet map. At the end, there is a sample Internet route map from University of Colorado to Red Hat Mirror Sites in North America during year 2004. You are expected to draw similar maps.

To collect data, for example, by using command like

“pchar

you will find out Internet routes to with bandwidth and other information. Each test may take up to 60 minutes. For better accuracy, you have to repeat the above tests for 3 times during a dayand take the average result. Ideally, you should try to collect data for at least 7 days and take the average. However, I understand the time constrains you face in this lab. Therefore, data collected during one day is acceptable.

There are a number of tools available on the Internet which are more convenient and powerful than pchar. If you decide to use a different tool to finish this lab, you are more than welcome to do so.

I would like you to study internet routes to the following sites:

1)

2)

3) europa.eu (a portal site to European Union)

You need to run pchar at least 3 times during a day for each site. Therefore, you may need to write scripts to help you to finish the job. Make good use of linux text editing tools (i.e. grep) or MS excel if you don’t want to waste your time by manipulating data manually. Once you have gathered your data, draw some nice plots, and possibly an Internet map.

Question 1: write a report describing the scripts you wrote, the data you gathered (in plots or charts or map, no raw data and no tabular data, any interesting anomalies you observe,andconclusions you are able to draw from the data.

Section 2Configure Apache Web Server

a) Study httpd.conf

On the linux machine (referred as srv01 or srv01.contoso.com below), run

vi /*****/httpd.conf

/****/ is the path where httpd.conf sits.

Here are some most important directives in apache configuration file. Please take a look in httpd.conf and make sure you understand the meaning and usage.

ServerRoot
DocumentRoot
ServerName
User / Group
Listen
ServerAdmin
Transferlog,
errorlog,
pidfile
Keepalive,
keepalivetimeout
Timeout
MaxClients
MaxRequestsPerChild
Min/MaxSpareServers
StartServers

Question 2: After you modify httpd.conf, do you need to restart apache?

b) Change port

Modify httpd.conf so that the apache listens to port 8080 instead of 80. On srv01, run and observe the result. Change the port back to 80 after the test.

Question 3: which directive should you modify to change the port?

c) Web document directory

Modify httpd.conf so that the apache web document directory is changed from default to /root/web directory.

Create index.html under /root/web with the following content.

web document directory /root/web

visit and observe the result.

Question 4: which directive should you modify to change the web document directory?

d) Default Document

On srv01 web document root directory, create a file named start.htm. The content is as follows.

This is start.htm file

Please set the default document of srv01.contoso.com to start.htm.

Question 5: Why to use default document? How to change default document?

e) Configure MIME

On srv01 web document rootdirectory, create a file named test.xyz. It is a plain text file. The content is as below.

This is a test file for MIME configuration

Access

Please configure the MIME setting on srv01 so that the web server knows how to deal with *.xyz file.

Question 6:Please briefly describe how to change MIME settings with .xyz type.

Section 3: .htaccess file

In this section, we are going to learn how to use .htaccess file to protect your web documents or web folders. If web users want to visit protected documents, he will be asked for username and password like below.

a) Modify httpd.conf

On srv01, modify httpd.conf file to enable .htaccess control. Find the following in httpd.conf file.

<Directory “/var/www/html/”>

AllowOverride All
....
</Directory>

Make sure “AllowOverride” is set to All.

Question 7: Why to set AllowOverride to All?

b) Create .htaccess

On srv01, run

cd /var/www/html/
mkdir sales
cd sales
vi index.html
(type “test for sales” in vi for the content of index.html)

We want to use .htaccess to protect sales sub-directory.
Run

vi .htaccess

Type the following content in .htaccess

AuthType Basic
AuthName "Restricted Access Zone for
AuthUserFile /var/www/html/sales/.htpasswd
Require valid-user

c) Create .htpasswd

Now we need to create .htpasswd file which contains username and password information.

On srv01, Run

cd /var/www/html/sales/
htpasswd -c .htpasswd mike
(enter password: k)
htpasswd htpasswd jack
(enter password: k)
htpasswd htpasswd smith
(enter password: k)

This will create a .htpasswd file under current directory, and add users mike, jack, smith.

Run

vi .htpasswd

to take a look at .htpasswd file.

d) Restart web server

e) Check web user authentication

Open browser, visit:

You should see a pop-up window asking for username and password. Input any of the accounts you created.

Question 8: please take a screenshot to show the running result above

Question 9:what information is stored in .htaccess?

Question 10:what information is stored in .htpasswd?

Section 4Apache Virtual Host

You can host multiple websites on one machine using virtual host technology in Apache. You can do virtual hosting based on port, IP or domain name.

a) Port-based virtual hosting

On srv01, create a directory /web and sub-dir /web/port, create an index.html file in /web/port. The content is as follows.

Test web page under /web/port directory.

Remember to change the access right of /web, /web/port, and /web/port/index.html. You can use the following command

chmod 755 *****

**** is the directory or file

Modify httpd.conf and add the following content at the end of the conf file.

Listen 8000
VirtualHost 192.168.11.43:8000>
DocumentRoot /web/port
<Directory “/web/port”>
Options None
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost

(Replace the IP with your real IP, same for all instructions below)

This creates a new virtual host which listens to port 8000 on server IP 192.168.11.43. And the web document is in /web/port. We also grant access for all to that directory.

Restart httpd.

On srv01, open web browser and access you should be able to view the web page.

Question 11:When should you use port based virtual hosting, give a couple of examples?

b) Name-based virtual hosting

This is similar to host header in IIS. On srv01, create directories of /web/cat and /web/dog. Create index.html under those two directories accordingly. Remember the change the access mode.

Modify /etc/hosts file to configure the following DNS records.

/ 192.168.11.43 (or your real IP)
/ 192.168.11.43 (or your real IP)

On srv01, modify httpd.conf and add the following content at the end of the conf file.

NameVirtualHost *:80
VirtualHost *:80
ServerName
DocumentRoot /web/cat
</VirtualHost
VirtualHost *:80
ServerName
DocumentRoot /web/dog
</VirtualHost

Restart httpd. On srv01, open web browser and access and you should be able to view the web pages.

If you are not able to view web pages (forbidden to access), then you need to configure <directory> which is similar to step (a).

Question 12: please take a screenshot of the httpd.conf file to show virtual host related sections.

Question 13: please take a screenshot on web browser to show

Question 14:When should you use name based virtual hosting, give a couple of examples?

Due to the time constrain, we will not do IP-based virtual hosting in this lab.

Answer Sheet

======Required Questions ======

Question 1: write a report describing the scripts you wrote, the data you gathered (in plots or charts or map, no raw data and no tabular data, any interesting anomalies you observe,andconclusions you are able to draw from the data.

Question 2: After you modify httpd.conf, do you need to restart apache?

Question 3: which directive should you modify to change the port?

Question 4: which directive should you modify to change the web document directory?

Question 5: Why to use default document? How to change default document?

Question 6:Please briefly describe how to change MIME settings with .xyz type.

Question 7: Why to set AllowOverride to All?

Question 8: please take a screenshot to show the running result above

Question 9:what information is stored in .htaccess?

Question 10:what information is stored in .htpasswd?

Question 11:When should you use port based virtual hosting, give a couple of examples?

Question 12: please take a screenshot of the httpd.conf file to show virtual host related sections.

Question 13: please take a screenshot on web browser to show

Question 14:When should you use name based virtual hosting, give a couple of examples?