DEV Community

Fabian
Fabian

Posted on • Edited on

Nginx

Goal:

Have nginx serve a custom static html file.

Nginx

The front-desk receptionist to my web traffic.

Path setup

I added a new path '/var/www/app' inside
sudo nano /etc/nginx/sites-available/app.mynextjsapp.com

Here we are adding our custom html file.

sites-available vs sites-enabled

sites-available: the folder where you keep all your websites active or inactive
sites-enabled: a folder containing symbolic links(see below) to point to the active files inside sites-available.

Symlinks

A symbolic link is essentially a Linux shortcut

The -s flag in ln -s stands for symbolic.

I need both paths to point to the same direction. Currently they are two seperate folders.

sudo ln -s /etc/nginx/sites-available/app.mynextjsapp.com /etc/nginx/sites-enabled/app.mynextjsapp.com

I am basically saying:
"Create a shortcut named app.mynextjsapp.com inside /sites-enabled/ that points directly to the real file inside /sites-available/."

that's it. done.

I just created two subdomains

app.mynextjsapp.com
dev.mynextjsapp.com (will use later)

which both point to the same IPv4 address of my hetzner cloud server. this will later achieve two functional environments on one hetzner bill plan.

Nginx with let's encrypt

I followed this cool guide

now app.mynextjsapp.com can be accessed on https :)

Top comments (0)