Difference between revisions of "OPS345 Lab 3"

From CDOT Wiki
Jump to: navigation, search
(Replaced content with "[http://wiki.littlesvr.ca/wiki/OPS345_Lab_3 This page has moved.]")
 
(34 intermediate revisions by the same user not shown)
Line 1: Line 1:
* www instance was created in the last lab, with a static private IP, and port fowarding done from port 2211 on router to port 22 on www.
+
[http://wiki.littlesvr.ca/wiki/OPS345_Lab_3 This page has moved.]
* yum install httpd iptables-services
 
* enable iptables
 
* before starting the service, we'll configure the server to store all webpages on a separate volume: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-attaching-volume.html
 
** 1GB in us-east-1a
 
** rename to www-data
 
** attach to www (note reboot is not required)
 
* ls /dev/xvd* -l > /dev/xvdf
 
* vgcreate vg_www /dev/xvdf
 
* lvcreate -n lv_www -l 100%FREE vg_www
 
* blkid
 
* ls /dev/mapper/vg_www-lv_www
 
* mkfs.ext4 -L www /dev/mapper/vg_www-lv_www
 
* vi /etc/fstab
 
** /dev/mapper/vg_www-wwwLV1 /var/www ext4 defaults 0 0
 
* mount /var/www/
 
* ls /var/www/
 
* mount | grep /dev/xvd
 
* ls /var/www/
 
* mkdir /var/www/html
 
* vi /var/www/html/index.php<source>
 
Hello. My web server still works.<br />
 
If this shows the current date and time, PHP works too:<br />
 
<?php system("date"); ?></source>
 
* chown -R andrew /var/www/html
 
* systemctl start httpd
 
* On router: iptables -t nat -I PREROUTING -p tcp --dport 80 -j DNAT --to 10.3.45.11:80
 
* On www: iptables -I INPUT 3 -p tcp --dport 80 -j ACCEPT
 
* service iptables save
 
* Edit security group, allow HTTP
 
* ss -atnp on router and www
 
* install php, restart httpd
 
* make proper html page:<source>
 
<html>
 
<head>
 
<style>
 
body  {background-color: powderblue;}
 
table {border-spacing: 1cm 0cm;}
 
h2    {color: blue;}
 
th    {text-align: left;}
 
p    {color: red; font-weight: bold;}
 
</style>
 
</head>
 
<body>
 
Hello. My web server still works.<br />
 
If this shows the current date and time, PHP works too:<br /><br />
 
<?php system("date"); ?>
 
<h2>Instance Info</h2>
 
<table>
 
<tr><th>Configuration</th><th>Value</th></tr>
 
<tr>
 
  <td><p>Private IP</p></td>
 
  <td><?php system("curl http://169.254.169.254/latest/meta-data/local-ipv4"); ?></td>
 
</tr>
 
<tr>
 
  <td><p>Public IP</p></td>
 
  <td><?php system("curl http://169.254.169.254/latest/meta-data/public-ipv4"); ?></td>
 
</tr>
 
</table>
 
<h2>Very simple web app using <a href="http://phpqrcode.sourceforge.net/">PHP QR Code</a></h2>
 
<img src="<?php
 
 
 
?>" />
 
</body>
 
</html>
 
</source>
 
* stop router www instances
 
* disable "auto-assign public IPv4 address" for subnet-ops345
 
* reassociate elastic ip with router
 
* start router and www
 

Latest revision as of 02:42, 28 February 2022