Search code examples
linodehugocaddycaddyfile

Caddy server with proxy to hugo server failing to load CSS


I'm running a caddy server on a linode instance with debian installed. I'm using the caddy server to proxy to a hugo server. The hugo server works locally, but does not through the caddy server. It will load the content, but style.min.css and the favicons won't load with an error like the following:

GET https://localhost:8081/css/style.min.css net::ERR_CONNECTION_REFUSED

Any help getting this working would be great!

Caddyfile:

mycustomdomain.com {
  root /home/sean/mycustomdomain.com
  gzip
  proxy / localhost:8081
  tls {
    dns linode
  }
}

hugo command:

hugo server --disableLiveReload --port 8081

Solution

  • Figured it out, so answering for posterity:

    To resolve this, utilize the http.hugo plugin. The new Caddyfile looks like so:

    mycustomdomain.com {
      root /hugo/site/dir/public
      hugo /hugo/site/dir
      gzip
      tls {
        dns linode
      }
    }