P a g e 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
P a g e 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 Unit: Mb/s acr2-lookc 36 oarnet.cle oebc2-atm6 208 199.18.115 29 krc5-atm1 57 tc4-atm3 se1-atm3 90 concretel 28 164.107.126 55 cis.ohio 78 acr1-lookc iar1-lookc merit-its atm1-0-0 cc-rtr adm-rtr kedzie-rtr pa-rtr 84 203 177 17 mirror.pa < 20 20-100 100-500 500-1000 > 1000 acr2-sonet2 65 acr2-looks 361 coreouter2 xcore2.san 45 owen-nero 39 corv-car1-g 41 orstbrdr-gw 55 orstsw1-gw ubu.nws atm2-0 57 157.at-6-0 53 0.so-0-1-0 0.so-3-0-0 0.so-7-0-0 597 0.so-0-1-0 157 186.atm9-0 35 Cisco0.xm 120 c6509-core 19 mirror.pa ucar 361 484 gbr2-p60 gbr1-p60 405 gbr3-p80 305 gbr3-p70 331 gbr4-p80s 9984(314) 1856 ggrl-p370s 256 gbr2-p100 275 sl-bb22-sj att-gw nr1-p360 210 29 36 sl-bb20-ana 35 0.so-2-x11 0.so-2-x12 mes1.mae sl-bb23-ana 445 1237 34 1216 0.so-3-t11 0.so-3-t12s 148 128.161.3 sl-bb21-fw 25 sl-gw40-fw 0.so-6-t11 169 0.so-3-t12l 183 n233-150c 15 42 208.30 0.so-1-x11 so-1-0-x12 n233-150n 35 0.os-7-xr1 pos5-0 57 n233-150a 164.58.1 56 193.atm6 194 194.atm8 33 mirror.arc ilgw-okc 54 191.atm6 cybertrails 67 42 164.58.10 43 ihets-gw cyb-r2-atm0 15 atlas fillmore nin.cyber 427 192.205.32 323 591 gbr4-p70d c1-pos6-0 296 5632 gbr4-p80d c1-pos1-c 48 gr1-p3100 80 pacbell 512 gige2-1 128 atl 360 gw2-netrail 33 130 cc-rstone 54 trillian gbr3-p60d 717 2133 gbr4-p40a 114 gbr4-p30w c1-pos3-0 333 gbr3-p60w c1-pos2-0 3328 gbr3-p20n c1-pos1-n 675 gbr5-p60n wbb1-pos2 109 1.5 gbr3-p360n 10.252.0 52 3.3 12.125.50 mirror-no 981 true-love.r 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
P a g e 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.
P a g e 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.
P a g e 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
P a g e 6 Type the following content in.htaccess AuthType AuthName Basic "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
P a g e 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 All Order allow,deny Allow from all
P a g e 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 www.dog4u.com 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 www.cat4u.com DocumentRoot /web/cat </VirtualHost> <VirtualHost *:80> ServerName www.dog4u.com DocumentRoot /web/dog </VirtualHost>
P a g e 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?