-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec2nginx
More file actions
70 lines (45 loc) · 1.89 KB
/
ec2nginx
File metadata and controls
70 lines (45 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
✅ Step-by-Step: Run Custom Nginx Page with Docker on EC2 (Ubuntu)
Update the system
Run: sudo apt-get update -y
Install Docker
Run: sudo apt install docker.io -y
Pull the official Nginx image
Run: sudo docker pull nginx
Run Nginx container on port 80
Run: sudo docker run -d -p 80:80 --name my-nginx nginx
Access the container shell
Run: sudo docker exec -it my-nginx bash
Navigate to the HTML folder
Run: cd /usr/share/nginx/html/
Install nano inside the container
Run: apt update and then apt install nano -y
Edit the homepage
Run: nano index.html
Inside the file, replace or edit the content with:
<h1>My Roll Number: 123456</h1>
To save and exit:
Press Ctrl + O and Enter to save
Press Ctrl + X to exit nano
Exit the container
Run: exit
Access the page in browser
Open your browser and go to: http://<your-ec2-public-ip>
You will see your custom Nginx page showing your roll number.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Configure Security Group
Allow the following inbound rules:
Type: SSH | Protocol: TCP | Port: 22 | Source: 0.0.0.0/0 | Description: For terminal (SSH) access
Type: HTTP | Protocol: TCP | Port: 80 | Source: 0.0.0.0/0 | Description: For browser access
Type: HTTPS | Protocol: TCP | Port: 443 | Source: 0.0.0.0/0 | Description: For secure web access (optional)
Connect to your EC2 instance using SSH
Example: ssh -i "your-key.pem" ec2-user@<public-ip>
Install Apache Web Server (httpd)
Run the following commands on the instance:
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
(Optional) Add your own content
Replace the default page at /var/www/html/index.html with your own content using a text editor like nano.
Access the site
Open your browser and go to: http://<your-ec2-public-ip>