Member-only story

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…

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Joseph Gefroh
Joseph Gefroh

Written by Joseph Gefroh

VP of Product and Engineering @ HealthSherpa. Opinions my own. Moved to Substack. https://jgefroh.substack.com/

Responses (27)

What are your thoughts?

THANK YOU SO MUCH FOR THIS ARTICLE!!!! I got myself into a client situation where I have finished the site, but can’t get nginx up-and-running, and the client’s already breathing down my neck about it. Your article fixed all of that. Thank you, thank you, thank you!

Hello,
I got 404 errors when clicking links in my react website, and wondering around I found that the solution is to modify the "location" config in this way:
location / {
try_files $uri /index.html;
}
This is because there are no html pages on the…

This was super helpful, thanks so much for this walk through.
For me, the SSL section was a little different as when I ran the 'sudo add-apt-repository ppa...'' line, it said PPA is now deprecated. i instead followed the instructions from certbot and all was fine.
Thanks again for this, learnt a tonne of info.