In this tutorial, you’ll install Nginx on a Raff Ubuntu 24.04 VM, allow web traffic through UFW, verify the default Nginx page, and create a custom server block to serve your own web page.
Nginx is a lightweight, high-performance web server commonly used for static websites, reverse proxy setups, load balancing, and application hosting. This tutorial uses Ubuntu’s default package repository, configures firewall access, creates a test site, validates the Nginx configuration, and confirms the server block works before you move on to HTTPS or application hosting.
Raff Technologies runs over 10,000 VMs across its compute platform in Vint Hill, Virginia, on AMD EPYC hardware with NVMe storage.
Prerequisites:
- A Raff Ubuntu 24.04 VM
- SSH access with sudo privileges
- Ports
80/tcpavailable for web traffic - A domain or subdomain if you want to use a real hostname, optional for this tutorial
This tutorial was tested on a Raff VM with 2 vCPU, 2 GB RAM, running Ubuntu 24.04.4 LTS.
Tested on Raff infrastructure by Aybars Altınyay, platform engineer and technical writer at Raff Technologies.
Step 1 — Update Ubuntu and install Nginx
Update the package index and install Nginx from Ubuntu’s default package repository.
sudo apt update sudo env DEBIAN_FRONTEND=noninteractive NEEDRESTART_MODE=a apt upgrade -y \ -o Dpkg::Options::=--force-confdef \ -o Dpkg::Options::=--force-confold sudo apt install -y nginx ufw curl
📌 Note: If Ubuntu asks what to do with a modified
/etc/ssh/sshd_configfile, select keep the local version currently installed. This preserves your current SSH login configuration.
Verify the Ubuntu version and installed Nginx version:
lsb_release -ds nginx -v
Expected output:
Ubuntu 24.04.4 LTS nginx version: nginx/1.24.0 (Ubuntu)
Minor Ubuntu 24.04 point releases are acceptable.
Step 2 — Verify the Nginx service
Nginx starts automatically after installation. Confirm that the service is active:
systemctl is-active nginx
Expected output:
active
You can also view the full service status:
sudo systemctl status nginx
Expected output includes:
Active: active (running)
The most common Nginx service commands are:
sudo systemctl stop nginx sudo systemctl start nginx sudo systemctl restart nginx sudo systemctl reload nginx sudo systemctl enable nginx sudo systemctl disable nginx
Use reload after configuration changes when you want Nginx to apply the new configuration without fully stopping the service.
Step 3 — Configure the UFW firewall
Allow SSH first so you do not lock yourself out of the VM.
sudo ufw allow OpenSSH
Allow HTTP traffic on port 80.
sudo ufw allow 80/tcp
Enable UFW:
sudo ufw --force enable
Verify the firewall rules:
sudo ufw status numbered
Expected output includes:
Status: active OpenSSH ALLOW IN 80/tcp ALLOW IN
⚠️ Warning: Always allow
OpenSSHbefore enabling UFW. If SSH is blocked, you may lose access to the VM.
Step 4 — Test the default Nginx page
Verify Nginx responds locally:
curl -I http://localhost
Expected output includes:
HTTP/1.1 200 OK Server: nginx/1.24.0 (Ubuntu)
Find your VM’s public IP address:
curl -4 icanhazip.com
Open your browser and visit:
http://your_server_ip
You should see the default Nginx welcome page.
Visible state check:
The browser shows the default Nginx welcome page. The page includes the message "Welcome to nginx!" The browser uses HTTP because HTTPS has not been configured yet.

This confirms that Nginx is installed, running, and reachable through the firewall.
Step 5 — Create a custom Nginx server block
Nginx uses server blocks to serve different websites from different directories or hostnames. In this step, you’ll create a small demo site and configure Nginx to serve it.
Create a document root for the demo site:
sudo mkdir -p /var/www/raff-nginx-demo/html
Create a custom HTML page:
sudo tee /var/www/raff-nginx-demo/html/index.html > /dev/null <<'EOF' <!doctype html> <html> <head> <meta charset="utf-8"> <title>Nginx server block is working on Raff</title> <style> body { font-family: Arial, sans-serif; background: #111; color: #fff; max-width: 720px; margin: 120px auto; line-height: 1.6; } h1 { color: #db4a2b; } </style> </head> <body> <h1>Nginx server block is working on Raff</h1> <p>This custom Nginx page is served from an Ubuntu 24.04 VM on Raff Technologies.</p> </body> </html> EOF
Capture your server’s public IP address:
SERVER_IP="$(curl -4s icanhazip.com)" echo "$SERVER_IP"
Create a new Nginx server block:
sudo tee /etc/nginx/sites-available/raff-nginx-demo > /dev/null <<EOF server { listen 80; listen [::]:80; server_name ${SERVER_IP}; root /var/www/raff-nginx-demo/html; index index.html; location / { try_files \$uri \$uri/ =404; } } EOF
Enable the server block:
sudo ln -sf /etc/nginx/sites-available/raff-nginx-demo /etc/nginx/sites-enabled/raff-nginx-demo
Test the Nginx configuration:
sudo nginx -t
Expected output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
Reload Nginx:
sudo systemctl reload nginx
Step 6 — Verify the custom server block
Test the custom page from the command line:
SERVER_IP="$(curl -4s icanhazip.com)" curl -s "http://$SERVER_IP" | head
Expected output includes:
<title>Nginx server block is working on Raff</title>
Open your browser and visit:
http://your_server_ip
You should see the custom Raff demo page.
Visible state check:
The browser shows the custom Nginx server block page. The page includes the message "Nginx server block is working on Raff". The page is served from /var/www/raff-nginx-demo/html.

The custom server block is working when the browser and curl both return the custom demo page.
📌 Note: For production websites, replace the IP-based
server_namewith your actual domain, such asexample.com www.example.com, and point the domain’s DNS records to your Raff VM.
Step 7 — Review important Nginx files and directories
Now that Nginx is running, it helps to know the key files and directories.
Content directories:
/var/www/html/ /var/www/raff-nginx-demo/html/
Configuration directories:
/etc/nginx/nginx.conf /etc/nginx/sites-available/ /etc/nginx/sites-enabled/ /etc/nginx/conf.d/
Log files:
/var/log/nginx/access.log /var/log/nginx/error.log
The most important files from this tutorial are:
/var/www/raff-nginx-demo/html/index.html /etc/nginx/sites-available/raff-nginx-demo /etc/nginx/sites-enabled/raff-nginx-demo
Check recent Nginx access logs:
sudo tail -n 20 /var/log/nginx/access.log
Check recent Nginx error logs:
sudo tail -n 20 /var/log/nginx/error.log
If the error log is empty or shows no recent errors, that is a good sign.
Step 8 — Verify the complete Nginx setup
Run a final verification sequence:
SERVER_IP="$(curl -4s icanhazip.com)" echo "Checking service:" systemctl is-active nginx echo "Checking configuration:" sudo nginx -t echo "Checking firewall:" sudo ufw status numbered echo "Checking default HTTP response:" curl -I "http://$SERVER_IP" echo "Checking custom page:" curl -s "http://$SERVER_IP" | grep "Nginx server block is working on Raff"
Expected output includes:
active nginx: configuration file /etc/nginx/nginx.conf test is successful Status: active HTTP/1.1 200 OK Nginx server block is working on Raff
The Nginx setup is complete when the service is active, the configuration test passes, UFW allows HTTP traffic, and the custom page loads in the browser.
Cleanup (Optional)
Use this section only if you want to remove the demo Nginx server block from the VM.
Remove the demo server block and web root:
sudo rm -f /etc/nginx/sites-enabled/raff-nginx-demo sudo rm -f /etc/nginx/sites-available/raff-nginx-demo sudo rm -rf /var/www/raff-nginx-demo
Test and reload Nginx:
sudo nginx -t sudo systemctl reload nginx
If this VM no longer needs to serve HTTP traffic, remove the firewall rule:
sudo ufw delete allow 80/tcp sudo ufw status numbered
⚠️ Warning: Do not remove port
80/tcpif this VM still hosts websites, reverse proxies, or HTTP-to-HTTPS certificate issuance flows.
Troubleshooting
The browser does not load the Nginx page
Cause: Nginx is not running, port 80 is blocked, or the wrong IP address is being used.
Fix:
systemctl is-active nginx sudo ufw status numbered curl -4 icanhazip.com curl -I http://localhost
Expected output includes:
active 80/tcp ALLOW IN HTTP/1.1 200 OK
sudo nginx -t shows a syntax error
Cause: The server block contains a typo or invalid Nginx directive.
Fix:
sudo nginx -t sudo nano /etc/nginx/sites-available/raff-nginx-demo
After fixing the file, test and reload again:
sudo nginx -t sudo systemctl reload nginx
The default Nginx page still appears after creating the server block
Cause: The browser is still receiving the default site, or the server_name does not match the request.
Fix:
SERVER_IP="$(curl -4s icanhazip.com)" grep server_name /etc/nginx/sites-available/raff-nginx-demo curl -H "Host: $SERVER_IP" "http://$SERVER_IP"
If needed on a fresh test VM, disable the default site:
sudo rm -f /etc/nginx/sites-enabled/default sudo nginx -t sudo systemctl reload nginx
Then refresh the browser.
UFW blocks web traffic
Cause: HTTP traffic is not allowed through the firewall.
Fix:
sudo ufw allow 80/tcp sudo ufw status numbered
Expected output includes:
80/tcp ALLOW IN
Nginx reload fails
Cause: Nginx only reloads when the configuration is valid.
Fix:
sudo nginx -t sudo journalctl -u nginx --no-pager -n 50
Resolve the reported configuration error, then reload again:
sudo systemctl reload nginx
Conclusion
You have installed Nginx on a Raff Ubuntu 24.04 VM, configured UFW to allow web traffic, verified the default Nginx page, created a custom server block, and confirmed the server serves your custom page correctly.
From here, you can secure the site with HTTPS, use Nginx as a reverse proxy, host static websites, or build a full web application stack on the same Raff VM. If you haven’t deployed your Raff VM yet, you can spin one up in 60 seconds at rafftechnologies.com.
Next: Secure Nginx with Let’s Encrypt on Ubuntu 24.04 Related: Set Up a LEMP Stack on Ubuntu 24.04 Guide: Install Docker on Ubuntu 24.04
