Notes on Nginx and Hugo

Notes on Nginx and Hugo

July 29, 2024
2024, Engineering
Devops, Nginx, Hugo

tldr #

We got Rubber Ducky and FineAI working again. Both of these assets are built using Hugo.

Overall steps #

  1. Starting a new site
  2. Installing theme
  3. Writing some content
  4. Version controlling it
  5. Writing a Nginx’s config
  6. Ensuring sub-domains are mapped correctly
  7. Ensure SSL is working on the sub-domain

Significance of this activity is: With Nginx we can map multiple sites onto a single server. Since traffic is not much, we can map multiple sites onto single machine.

Deployment script #

  1. Pulling code from Repo
  2. Building static site
  3. Copying contents over to /var/www/html

The original config file for Nginx is written something along the lines

server
{
        listen 80;
        listen [::]:80;

        server_name fineai.com;

        index index.html;

        location /
        {
                alias /var/www/html/fineai/;
                try_files $uri $uri/ =404;
                autoindex on;
                autoindex_exact_size off;
        }

}

Key things to note above:

  1. server_name this tells which domain a particular config applies to
  2. alias is similar to root but it basically tells Nginx where to look fro HTML files
  3. Once config is working correctly we need to run certbot to ensure SSL is installed
  4. Don’t forget to add asset to Uptime