Nginx
Nginx is a high-performance web server, reverse proxy, and load balancer that powers a large share of the busiest sites on the internet. It serves static content efficiently, proxies requests to application backends, and terminates TLS with a small memory footprint.
Software included
Section titled “Software included”| Component | Version |
|---|---|
| Nginx | 1.30.3 |
| Ubuntu | 24.04 LTS |
Getting started
Section titled “Getting started”1. Connect to your VM
Section titled “1. Connect to your VM”ssh ubuntu@<your-vm-ip>2. Verify Nginx is running
Section titled “2. Verify Nginx is running”There is no first-boot configuration. Nginx starts immediately after the VM boots.
systemctl status nginx3. Access the default site
Section titled “3. Access the default site”Open a browser and navigate to:
http://<your-vm-ip>You can also verify the response from the VM:
curl -I http://localhostManaging Nginx
Section titled “Managing Nginx”# Check service statussystemctl status nginx
# Validate the configurationsudo nginx -t
# Restartsudo systemctl restart nginx
# View logssudo journalctl -u nginx -f| Path | Purpose |
|---|---|
/etc/nginx/nginx.conf | Main configuration |
/etc/nginx/conf.d/ | Server and proxy configuration |
/usr/share/nginx/html/ | Default web root |
Security
Section titled “Security”Ports 80 and 443 are open on the VM’s network interface. UFW is enabled and allows HTTP (port 80), HTTPS (port 443), and SSH (port 22). Nginx serves HTTP on port 80 by default. Port 443 has no TLS listener until you configure a certificate and HTTPS server block.
To restrict HTTP and HTTPS to a specific IP:
sudo ufw delete allow 80/tcpsudo ufw delete allow 443/tcpsudo ufw allow from <trusted-ip> to any port 80sudo ufw allow from <trusted-ip> to any port 443To access the default site without leaving port 80 open, use an SSH tunnel:
# Run this on your local machinessh -L 8080:localhost:80 ubuntu@<your-vm-ip>
# Then open in a browserhttp://localhost:8080For production use, configure Nginx with a trusted TLS certificate and serve public sites on port 443. Nginx does not add authentication to proxied services, so protect each upstream application separately.