Deploy to server

Pre-requisites

  • A website built with Hugo (i.e the generated public folder)

Folder structure

  • cd into the apps folder created earlier
  • Create a new folder for your website mkdir blog-site
  • cd blog-site
  • Pull the public folder from the git repository of the public folder
    • git clone <repo-url>
    • If your repo is private, you can use the following command:
    • git clone https://username:[email protected]/username/blog-site.git

Nginx setup

  • How I did this was that I created a new nginx container (not Nginx Proxy Manager) and mounted the public folder to /usr/share/nginx/html in the container.
  • Here’s the docker-compose.yml file for the container:
# ~/apps/blog-site/docker-compose.yml
version: '3.8'

services:
  blog:
    container_name: 'blog'
    image: 'nginx:stable'
    restart: unless-stopped
    expose:
      - '80:80'
    volumes:
      - ./<path-to-cloned-folder>:/usr/share/nginx/html
    networks:
      - my-services

networks:
  my-services:
    name: 'my-services'
    external: true

Configure Nginx Proxy Manager

  • Now, we will configure Nginx Proxy Manager to proxy requests to our website.
  • Go to the Nginx Proxy Manager dashboard and click on Proxy Hosts tab.
  • Click on Add Proxy Host and fill in the details: New Proxy Host New Proxy Host
  • Go to the SSL tab and select the SSL certificate we created earlier. SSL Certificate SSL Certificate
  • Save the configuration and visit your domain. You should see your website.