Day 4: Nginx Website Deployment

CloudDevOpsHub Batch 45 | Guided by Vikas Ratnawat Sir

1. What is Nginx?

Nginx is a web server that can serve static HTML, CSS, JavaScript and image files. It can also act as a reverse proxy. In this project, Nginx serves the website from /var/www/html.

2. Check the service

sudo systemctl status nginx --no-pager
sudo systemctl is-active nginx

The service should report active when running. Use q to exit a status view if needed.

3. Understand the website directory

ls -lah /var/www/html

Files in this directory may be served by the default Nginx site. Check your active Nginx configuration before changing document roots.

4. Validate and reload Nginx

sudo nginx -t
sudo systemctl reload nginx

Run the configuration test before reloading. A reload applies configuration changes without intentionally stopping the service. For HTML-only changes, a reload is normally unnecessary.

5. Verify the website

curl -I http://localhost/
curl -s http://localhost/ | head

Open the server's public IP address in a browser to check the site. If it does not load, check the cloud firewall rules and confirm that HTTP port 80 is allowed only as intended.

6. Deployment checklist

Do not expose SSH (port 22) to everyone unless required. Restrict administrative access to trusted IP addresses when possible.

Revision Questions

  1. What is Nginx used for?
  2. Where are the current website files stored?
  3. Why run nginx -t before a reload?
  4. What should you check if the public website is unreachable?