The BobSprite Raw Blog

Pixel Art, Programming and Video Games

(click here and go to index)

How to Write a Simple NGINX Directive File

NGINX text logo
NGINX is very nice except for its config files that are hard to write. If you just want to have your basic Nginx stuff done, then maybe the model that I have been using for years is what you need.


This model expects that Let's Encrypt is the choice for the   HTTPS   protocol.

This model expects that the index page is   "/home.html".

This model expects that the error page is   "/404.html".

This model redirects   HTTP   protocol requests to   HTTPS   protocol.

This model redirects   ""   to   "".

This model redirects   ""   to   "".

Of course it serves files that have the   ".html"   extension for requests that don't have this extension.

It used to pass requests for "/analytics" to an internal NodeJs server but it is disabled now. So it responds with "[under construction]".

Editing the Model

You must replace "bobsprite" everywhere with your own domain.

You must replace "/home.html" using your index page address, in case it is different.

You must replace "/404.html"  using your error page address, in case it is different.


I don't like CertBot messing my config files. So I *never* use this command:

sudo certbot --nginx

But I use this:

sudo certbot certonly --nginx

The Model

NGINX directive

The directive above is an image. You may access this directive text file here.

I hope it helps!


I am not a server expert.