webi-installers icon indicating copy to clipboard operation
webi-installers copied to clipboard

docs for Caddy cheatsheet

Open coolaj86 opened this issue 4 years ago • 2 comments

Needs how to run a quick-n-dirty local server:

# local-ish http-only file browser
# caddy hash-password
http://example.duckdns.org:3000 {
	basicauth / {
		myusername JDJhJDE0JFVMRGJ3TVR4YXlOc2x5U2N6cldPSE9kOVFaZzZ0V2JjSThySEFVbGQuTWljT0pCYVBzamk2
	}
	basicauth /* {
		myusername JDJhJDE0JFVMRGJ3TVR4YXlOc2x5U2N6cldPSE9kOVFaZzZ0V2JjSThySEFVbGQuTWljT0pCYVBzamk2
	}
	root * /Volumes/Storage/Shared/
	file_server {
	  browse
    }
}

coolaj86 avatar Jan 12 '22 00:01 coolaj86

How to download caddy with a Let's Encrypt DNS-01 plugins:

  • Home page
  • Download
  • Filter Packages & Modules

Examples

  • DNSimple (via Lego)
  • DuckDNS

DNSimple (via Lego)

Caddy with Lego: https://caddyserver.com/download?package=github.com%2Fcaddy-dns%2Flego-deprecated

  • List of supported DNS providers: https://github.com/go-acme/lego#dns-providers
  • Each page will list the "provider code" as well as the necessary ENVs, such as https://go-acme.github.io/lego/dns/dnsimple/
example.com {
    tls {
        dns lego_deprecated dnsimple
    }
}
# to provide the token directly
export DNSIMPLE_OAUTH_TOKEN=xxxxxxxxx
# to provide the token from a file instead
export DNSIMPLE_OAUTH_TOKEN_FILE=/path/to/token.txt

You can put creds in a .env and run with dotenv:

dotenv -f .env -- caddy run --config Caddyfile

DuckDNS

Caddy with DuckDNS: https://caddyserver.com/download?package=github.com%2Fcaddy-dns%2Fduckdns

  • Linux x64: https://caddyserver.com/api/download?os=linux&arch=amd64&p=github.com%2Fcaddy-dns%2Fduckdns&idempotency=79220249565097
example.duckdns.org {
    tls {
        dns duckdns xxxxxxxx-xxxx-4xxx-8xxx-xxxxxxxxxxxx    
    }
}

Or

example.duckdns.org {
    tls {
        dns duckdns {env.DUCKDNS_API_TOKEN}
    }
}

coolaj86 avatar Feb 13 '22 03:02 coolaj86

Exclude Dev Sites from Search Engines

dev.example.com {
    header {
        Link "<https://production.example.com{http.request.orig_uri}>; rel=\"canonical\""
        X-Robots-Tag noindex
    }
}
curl -I https://dev.example.com
HTTP/2 200
accept-ranges: bytes
content-type: text/html; charset=utf-8
etag: "xxxxxxxxxxxx"
last-modified: Mon, 13 Dec 2021 23:18:16 GMT
link: <https://production.example.com/>; rel="canonical"
server: Caddy
x-robots-tag: noindex
content-length: 4242
date: Fri, 04 Mar 2022 00:27:55 GMT

See

  • https://developers.google.com/search/docs/advanced/robots/intro
  • https://developers.google.com/search/docs/advanced/crawling/block-indexing

coolaj86 avatar Mar 04 '22 00:03 coolaj86

Included in #649

coolaj86 avatar Oct 19 '23 20:10 coolaj86