word document

advertisement
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 1 Investigate 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 pchar to 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
www.cnn.com”,
you will find out Internet routes to www.cnn.com 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 day and 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) www.cnn.com
2) www.yahoo.com
Page |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, and
conclusions you are able to draw from the data.
Wait
26
CS
108
uccsedge
128
uccs
64
141
acr2-sonet2
78
65
acr2-lookc
acr1-lookc
84
iar1-lookc
36
oarnet.cle
oebc2-atm6
208
199.18.115
45
atm1-0-0
203
cc-rtr
orstbrdr-gw
orstsw1-gw
177
se1-atm3
90
concretel
pa-rtr
9984(314)
0.so-3-0-0
mirror.pa
28
ggrl-p370s
0.so-0-1-0
186.atm9-0
35
Cisco0.xm
c6509-core
55
19
cis.ohio
mirror.pa
sl-bb22-sj
210
sl-bb20-ana
gbr2-p100
1216
sl-bb21-fw
sl-gw40-fw
42
ilgw-okc
54
164.58.10
gr1-p3100
80
35
0.so-2-x11
0.so-3-t11
0.so-2-x12
mes1.mae
1237
0.so-3-t12s
0.so-6-t11
169
0.so-1-x11
0.so-3-t12l
128.161.3
512
n233-150c
128
0.os-7-xr1
pos5-0
n233-150a
57
193.atm6
194
191.atm6
67
194.atm8
360
42
ihets-gw
cyb-r2-atm0
fillmore
nin.cyber
15
A sample Internet route map from Univ. of Colorado to Red Hat Mirror sites
Section 2 Configure Apache Web Server
a) Study httpd.conf
On the linux machine (referred as srv01 or srv01.contoso.com below), run
c1-pos3-0
gbr3-p60w
c1-pos2-0
333
gbr3-p20n
c1-pos1-n
gbr5-p60n
wbb1-pos2
675
109
130
gbr3-p360n
cc-rstone
33
cybertrails
gbr4-p30w
gw2-netrail
56
mirror.arc
2133
114
3328
atl
15
n233-150n
717
gbr4-p40a
gige2-1
25
183
so-1-0-x12
pacbell
34
148
43
atlas
nr1-p360
36
33
208.30
35
< 20
20 - 100
100 - 500
500 - 1000
> 1000
c1-pos1-c
48
gbr3-p60d
att-gw
29
445
sl-bb23-ana
164.58.1
Unit: Mb/s
gbr4-p80d
275
120
164.107.126
5632
1856
256
597
c1-pos6-0
331
gbr4-p80s
0.so-0-1-0
0.so-7-0-0
591
gbr4-p70d
296
53
157
ubu.nws
17
gbr3-p70
305
157.at-6-0
39
55
kedzie-rtr
192.205.32
323
405
gbr3-p80
41
adm-rtr
57
tc4-atm3
owen-nero
corv-car1-g
29
krc5-atm1
xcore2.san
gbr1-p60
atm2-0
57
merit-its
427
484
gbr2-p60
361
coreouter2
ucar
361
acr2-looks
54
trillian
52
12.125.50
981
true-love.r
1.5
10.252.0
3.3
mirror-no
Page |3
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
http://srv01.contoso.com:8080 and observe the result. Change the port back to 80 after the test.
Page |4
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.
www.contoso.com web document directory /root/web
visit http://srv01.contoso.com 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 root directory, 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 http://srv01.contoso.com/test.xyz
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.
Page |5
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
Page |6
Type the following content in .htaccess
AuthType Basic
AuthName
"Restricted Access Zone for www.contoso.com"
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:
http://srv01.contoso.com/sales
Page |7
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 4 Apache 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
<Directory
Options
/web/port
“/web/port”>
None
AllowOverride
Order
Allow
All
allow,deny
from
all
Page |8
</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 http://www.contoso.com:8000, 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.
www.cat4u.com
192.168.11.43 (or your real IP)
www.dog4u.com
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 www.cat4u.com
DocumentRoot
/web/cat
</VirtualHost>
<VirtualHost *:80>
ServerName www.dog4u.com
DocumentRoot
/web/dog
</VirtualHost>
Page |9
Restart httpd. On srv01, open web browser and access http://www.cat4u.com and
http://www.dog4u.com, 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 http://www.cat4u.com
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.
P a g e | 10
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, and
conclusions 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?
P a g e | 11
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 http://www.cat4u.com
Question 14: When should you use name based virtual hosting, give a couple of examples?
Download