Skip to content

Instantly share code, notes, and snippets.

@karlredman
Last active January 26, 2024 15:11
Show Gist options
  • Save karlredman/9f2299ce60529af2655c2ef1ab8670b7 to your computer and use it in GitHub Desktop.
Save karlredman/9f2299ce60529af2655c2ef1ab8670b7 to your computer and use it in GitHub Desktop.
# Serve static pages from minio through caddy

Serve static pages from minio through caddy

Assumptions:

  • caddy version (tested): 0.11.1
  • minio version (tested): `2019-01-10T00:21:20Z'
  • world facing domain URL is: http://localtest.me
    • add to hosts file if paranoid
    127.0.0.1       localtest.me
    
  • minio data storage directory: /data
  • minio static website bucket: /site
  • minio static website bucket index.html object: site/index.html
  • url for the local minio site/index.html instance object: http://localhost:9000/site/index.html
  • mc (the minio client) is configured as such for this minio instance:
    mc config host add myminio http://127.0.0.1:9000 <AccessKey> <SecretKey>
    

General procedure:

  1. start mnio server:
    ./minio server --address localhost:9000 /data
    
  2. create site bucket in minio
    mc mb myminio/site
    
  3. configure object folder for download policy
    mc policy download myminio/site
    
  4. copy files into site
    # example
    mc cp --recursive ~/MyHugoProject/public/* myminio/site/
    
  5. configure caddy config file Caddyfile
    http://localtest.me/myhugosite {
        rewrite / {
            r ^.*/$
            to {path} {path}/ {dir}/index.html
            }
        proxy / http://localhost:9000/site/ {
            #transparent #superfluious
        }
    }
    
  6. restart caddy
  7. test static site deployment: http://localtest.me/myhugosite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment