A guide to hosting static websites using NGINX

Learn how to host a static website using a VM and NGINX!

Joseph Gefroh
7 min readSep 4, 2017

NGINX is a very powerful web server. You can do a ton of things with it, such as setting up reverse proxies or load balancing. It can also be used to host your static website.

Now, keep in mind that there are many options when it comes to hosting static websites nowdays — Github pages, any number of hosting providers, Amazon S3 or Cloudfront, Cloudflare, etc. This is just one option among many.

Like this article? Add me on LinkedIn!

This guide assumes some things:

  • You’re comfortable using Linux.
  • You’re trying to host a basic static website on a VM.
  • You don’t know how to use NGINX.

Step 1: Get a server or a VM.

You’ll need shell access to follow this guide. I recommend a $5/month droplet from DigitalOcean, but it doesn’t really matter where it is.

Step 2: Point your domain name to the new server

Your domain name needs to point to your new server. Create an A record in your hosting provider’s DNS settings, pointing your domain name (eg. jgefroh.com) to the server IP address (eg. 127.0.0.1). If you don’t want to wait for the DNS to propagate, edit your /etc/hosts file to point your domain to the right IP address.

For the purposes of this guide, we’ll use the domain name jgefroh.com and the IP address 198.199.103.100 as examples. Switch out with your actual domain name and IP address as needed when you encounter these.

Step 3: Install NGINX

ssh into your server and use your favorite package manager to install NGINX. If using Ubuntu, you can run:

sudo apt-get update
sudo apt-get install nginx

Step 4: Move your website’s static files to the server

You can’t deliver your website if the server doesn’t have your files, so let’s add your files to the server.

--

--