webinstall / webi-installers

Primary and community-submitted packages for webinstall.dev
https://webinstall.dev
Mozilla Public License 2.0
1.9k stars 207 forks source link

docs for Caddy cheatsheet #390

Closed coolaj86 closed 11 months ago

coolaj86 commented 2 years ago

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 commented 2 years ago

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

Examples

DNSimple (via Lego)

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

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

example.duckdns.org {
    tls {
        dns duckdns xxxxxxxx-xxxx-4xxx-8xxx-xxxxxxxxxxxx    
    }
}

Or

example.duckdns.org {
    tls {
        dns duckdns {env.DUCKDNS_API_TOKEN}
    }
}
coolaj86 commented 2 years ago

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

coolaj86 commented 11 months ago

Included in #649