Skip to content
Ben's Tech
Go back

Registering a Domain and Setting Up NGINX

Edit page

Getting Started with a Custom Domain

The first step in setting up a self-hosted environment is securing a custom domain name. I registered a domain and updated the DNS A-records to point to my home network’s public IP address.

Since my home internet IP may change, I use a Dynamic DNS (DDNS) script to automatically update the DNS records. This ensures the domain always resolves to the correct IP address.

Setting up NGINX

With the domain pointing to my router, I forwarded ports 80 (HTTP) and 443 (HTTPS) to my local Linux server running NGINX.

NGINX acts as a reverse proxy. It receives incoming traffic from the internet and routes it to the various services running inside the home lab based on the requested subdomain.

Here is an example of an NGINX server block routing a subdomain to a local service:

server {
    listen 80;
    server_name myapp.example.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

After verifying the routes, I used Certbot and Let’s Encrypt to provision and configure SSL certificates for NGINX. This ensures all traffic to the domain is encrypted.

Launching the Blog with Astro and AstroPaper

To build the blog, I chose Astro, a static site generator.

For the design, I used the AstroPaper theme, which includes built-in dark mode, tags, and basic SEO features. I cleared out the default posts, updated the configuration files, and deployed the blog.

Because Astro builds static HTML files, serving them through NGINX is efficient and requires minimal system resources.


Edit page
Share this post on:

Previous Post
Embedding a Live ADSB Flight Tracker in Astro