Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

CS100 Intro to Web Applications

Module 12:
Deploying Websites
By CS100 Instructor Team
Department of Computer Science
Faculty of Science & Technology, Thammasat University
Last update: August 2023
Accessing Websites
● Client-Server Model:
HTTP Request & Response
● Client (e.g., Web Browser):
○ Sends HTTP requests to servers.

● Server (e.g., Web Server):


○ Listens for client requests
and sends appropriate
HTTP responses.
Credit: https://www.oreilly.com/library/view/hands-on-network-programming/9781789349863/c099d1ac-9bb2-46cb-9222-339617015438.xhtml

● Key Concepts:
○ URL (Uniform Resource Locator): Specifies where the requested data can be found.
○ HTTP Methods: Different types of requests like GET (retrieve), POST (submit data), PUT (update), DELETE.
○ HTTP Status Codes: Indicate the result of the request (e.g., 200 for success, 404 for not found).

2
Outline
● Basic of Web Hosting
○ Fundamental components of web servers
○ Network IP Address & Port
○ Document root directory
○ Security with firewall and key pair

● Hands-on with AWS Cloud and EC2


○ On-premise vs Cloud server
○ AWS and EC2 in Learner Lab
○ Deployment of Web Applications

3 Module 04: Git & Hosting


Expected Learning Outcomes
● Basic of Web Hosting
○ List the fundamental components required to host a website.
○ Describe the purpose and significance of the document root directory in web hosting.
○ Understand the role of ports in networking, specifically in web deployment.
○ Differentiate between inbound and outbound rules and explain their significance in the context of web servers.

● Hands-on with AWS Cloud and EC2


○ Explain the significance of cloud computing in modern web development.
○ Define what Amazon EC2 is and describe its primary functions.
○ Launch, configure, and manage an EC2 instance from the AWS console.
○ Set up and configure security groups for an EC2 instance to ensure secure web traffic and SSH connections.
○ Recognize the importance of key pairs and how they are used to securely connect to an EC2 instance.

● Deployment of Web Applications


○ Deploy a basic Node.js application on an EC2 instance and access it via a web browser.
○ Use user data scripts to automate setup processes on EC2, specifically for deploying Node.js applications.
○ Identify common issues that may arise during deployment and ways to resolve them.

4 Module 04: Git & Hosting


Basic of Web Hosting

5
Fundamental Components of Web Servers
Hardware components Software components
Processor (CPU): Operating System:
● The central unit that processes instructions. ● The primary software that manages hardware resources, e.g., Linux
● Faster processors can handle more simultaneous requests. (Ubuntu, CentOS), Windows Server.

Memory (RAM): Web Server Software:


● Temporary storage that provides quick data access for active processes. ● The software that handles HTTP requests and serves content to
● More RAM allows the server to handle more simultaneous users and users.
applications. ● Examples include Apache, Nginx, Microsoft IIS, and Tomcat.

Storage: Database Server:


● Permanent data storage, typically HDDs or SSDs. ● If the applications require it, software like MySQL, PostgreSQL, or
● Used for storing the operating system, server software, website files, MongoDB will be used to manage databases.
databases, and logs.

Network Interface Card (NIC): Scripting & Programming Languages:


● A hardware component that connects the server to the network, allowing ● Support for languages such as PHP, Python, Ruby, or JavaScript
it to communicate with other devices and serve content to users. allows the server to process dynamic content.
● Domain Name : Optional, but useful for user-friendly access. Otherwise, ● Libraries and tools required by web applications or the server
the server can be accessed via its public IP . software itself.

Power Supply: Security Tools:


● Provides the necessary power to the server components. ● Software firewalls, malware scanners, and intrusion detection
● Redundant power supplies can be used for higher availability. systems to ensure the security of the server.

6 Module 04: Git & Hosting


Fundamental Components of Web Servers
(cont.)
Software

7 Module 04: Git & Hosting


Network IP Address and Port
● IP Address: A unique number assigned to every device
connected to the internet, allowing them to
communicate.
○ Analogy: Think of an IP address like a street address for a house. It
tells you where someone lives on the vast "internet city".
○ Example: 192.168.1.1

● Ports: Numerical labels for endpoints of


communication, allowing specific types of data to be
received or sent.
○ Analogy: If the IP address is the street address, then ports are like
different doors or windows of that house. Each door or window (port)
has a specific purpose or service.
○ Common Ports: 80 HTTP (for web browsing), 443 HTTPS (secure web
browsing), 22 SSH (secure remote access)

Credit:
https://www.homenethowto.com/basics/ip-addresses/
https://www.dispersednet.com/redhat-system-admin/module4/define-port-numbers.php

8
Document Root Directory
● The "home" directory of your website

● Default location where web server looks File path on the Internet (accessible via a URL)
for files to display
○ Apache: Often found as /var/www/html
on Linux systems.
○ Nginx: Default might be
/usr/share/nginx/html or
/var/www/nginx on some systems.

● Acts as the starting point for your File path on the Web Server
website's file hierarchy credit: http://www.cellbiol.com/bioinformatics_web_development/chapter-3-your-first-web-page-learning-html-and-
css/hosts-domains-and-urls/

● Significance: Ensuring the correct files


are served when a domain is accessed

9
Security with Firewall
● Firewall: A network security system that monitors and filters incoming and outgoing network
traffic based on predetermined security policies.
○ Analogy: Think of a firewall as a security guard at the entrance of a building, deciding who can enter and
who can't based on a set of rules.

10 credit: https://www.quora.com/What-is-a-firewall-and-why-would-you-install-one-on-a-VPS
Security with Key Pair

● Key Pair: comprises two interconnected cryptographic keys: a public key and a private key.
● Public Key is like a lock on your front door.
○ Usage: Encrypt data or verify a signature.
○ Visibility: Can be shared openly without risk.

● Private Key is like the unique key that opens the lock on your front door.
○ Usage: Decrypt data or sign digital signatures.
○ Visibility: Must remain secret and secure. If lost or exposed, security is compromised.

11 credit: https://cheapsslweb.com/blog/what-is-a-public-and-private-key-pair
Hands-on with AWS
Cloud and EC2

12
Where to Host Your Websites

● On-Premise Web Server:


○ A physical server located within an organization's own facilities, managed and maintained by the in-house IT team.
○ Suitable for organizations needing utmost control, with dedicated IT teams and specific regulatory requirements.

● Cloud Server:
○ A virtual server hosted on a platform provided by a third-party cloud service provider (e.g., AWS, Azure, Google Cloud).
○ Ideal for businesses looking for flexibility, scalability, and reduced overhead, especially startups and those with
fluctuating demands.

13 Module 04: Git & Hosting


AWS Cloud and Amazon EC2
● Amazon Web Services (AWS) is a comprehensive and widely adopted cloud platform
offering various services, from computing power to storage options and beyond.
● Amazon Elastic Compute Cloud (EC2) is a part of AWS, offering scalable computing
capacity in the cloud.
○ Users can launch virtual servers, called "instances".

● Features:
○ On-Demand: Quickly launch, scale, and terminate virtual servers.
○ Customizable: Variety of instance types tailored for different use-cases.
○ Integrated: Works seamlessly with other AWS services.
○ Secure: Set up in network isolation and other security mechanisms.

14 Module 04: Git & Hosting


AWS Academy Learner Lab
● Each student should
receive a course invitation
via email.
● Create a new account and
login to the LMS
● Click ‘Forgot password’ if
you have any trouble
logging into the LMS

15
AWS Academy Learner Lab (cont.)
● You will see the
AWS Academy
Learner Lab in
the Dashboard
● Select ‘Launch
AWS Academy
Learner Lab’
● Agree to all lab’s
agreements
● Click ‘Start Lab’
and wait until
the circle next to
AWS turn green

16
Accessing Amazon EC2 via AWS Console

● Click at the AWS link next to the green circle


● Select ‘EC2’ and click ‘Launch instance’ to
create a new virtual server in the cloud to host
our website

17
Configuring EC2 Instances

● Name your instance


● Create a new key pair or select an existing key pair for later access
into the instance’s terminal
● Setup a security group’s rule for incoming traffic for ports 80 and 22
18
Configuring EC2 Instances (cont.)
● Use a shell script to setup the instance as a Web server
Install necessary software, e.g. Web server software like httpd

#!/bin/bash
# Use this for your user data (script from
top to bottom)
# install httpd (Linux 2 version)
yum update -y
yum install -y httpd
systemctl start httpd
Start the Web Server
systemctl enable httpd
echo "<h1>Hello World from $(hostname -
f)</h1>" > /var/www/html/index.html

Create an example page (in one line)

19
Checking out the deployed website
● View details of the successfully
launched instance
● View the example website in your
browser

Type http://35.174.153.63 in the web browser

20
Hands-On Activity
● Try launching an Amazon EC2 instance as shown in the previous example
○ Revisit Slide #6 again
○ Try your best to identify how each component can be identified in this example, note them down.

● If you encounter any issue along the way


○ Note down description of what happened
○ Why do you think is the cause of this issue? How did you find out?
○ What have you done to solve the issue?

21 Module 04: Git & Hosting


Discussion: Hands-On Activity

22
Discussion: Hands-On Activity (cont.)
Hardware components Software components
Processor (CPU): Operating System:
● 1 vCPU ● Amazon Linux 2023 (AL2023) - Fedora + CentOS

Memory (RAM): Web Server Software:


● 1.0 GiB ● Apache Web Server (httpd)

Storage: Database Server:


● 8 GiB EBS SSD Volume ● None

Network Interface Card (NIC): Scripting & Programming Languages:


● Domain Name and public IP are provided. ● None

Power Supply: Security Tools:


● Managed by AWS ● Software firewalls,i.e., security group
● Key pair to access the server

23
END

32 TITLE 24

You might also like