content:serverbasics:docker-caddy
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen der Seite angezeigt.
| Beide Seiten, vorherige ÜberarbeitungVorherige ÜberarbeitungNächste Überarbeitung | Vorherige Überarbeitung | ||
| content:serverbasics:docker-caddy [2024/01/12 21:41] – [Create Caddy Yaml] obel1x | content:serverbasics:docker-caddy [2025/06/05 23:27] (aktuell) – [Create Caddy Yaml] obel1x | ||
|---|---|---|---|
| Zeile 3: | Zeile 3: | ||
| Caddy is a powerful full featured webserver, which is also easy to use and setup. | Caddy is a powerful full featured webserver, which is also easy to use and setup. | ||
| - | In this guide i will show how to use Caddy as SSL- Proxy for your services to deliver them to the internet via name- based virtual hosting. | + | In this guide i will show how to use Caddy as SSL- Reverse- Proxy for your services to deliver them to the internet via name- based virtual hosting. |
| ===== Prerequisites ===== | ===== Prerequisites ===== | ||
| Zeile 11: | Zeile 11: | ||
| ===== DNS- Records ===== | ===== DNS- Records ===== | ||
| - | You will also need a domainname like '' | + | You will also need a domainname like '' |
| - | ==== Register some Domain ==== | + | |
| - | There are many free Domainproviders out there. I chose dynv6 ( [[https:// | + | When your service sucessfully resolves, you can use it in Caddy as written beneath. |
| - | bla (not ready) blah - setup IPV4 , setup IPV6, bla link to [[.: | ||
| - | |||
| - | ==== Define services ==== | ||
| - | |||
| - | After that, create an A-Name record (or AAAA- Name for ipv6) per service without specifying the ip, som that the dynamic ip of the domain will be taken. Only paste the servicename, | ||
| - | |||
| - | In our example this would be nice: | ||
| - | |||
| - | '' | ||
| ===== Create Caddy Yaml ===== | ===== Create Caddy Yaml ===== | ||
| Zeile 35: | Zeile 25: | ||
| < | < | ||
| - | version: " | ||
| - | |||
| services: | services: | ||
| caddy: | caddy: | ||
| Zeile 52: | Zeile 40: | ||
| - NET_ADMIN | - NET_ADMIN | ||
| healthcheck: | healthcheck: | ||
| - | test: "wget --no-verbose --tries=1 --spider https://obel1x.dynv6.net || exit 1" | + | test: "wget --no-verbose --tries=1 --spider https://www.servername.domainname.tld |
| interval: " | interval: " | ||
| timeout: " | timeout: " | ||
| start_period: | start_period: | ||
| retries: 3 | retries: 3 | ||
| - | # initially i wanted | + | # Be sure, that docker daemon has access |
| - | # it turned out not to work in rootless- mode for security reasons | + | # This can be archived by: |
| - | # so don't use host- mode. to access local services take the hostname directly, maybe define it static and add it to / | + | # setcap cap_net_bind_service=+ep / |
| - | # e.g. pcserver: | + | # |
| - | # NOT localhost: | + | # To access local services, take the hostname directly, maybe define it static and add it to / |
| + | # Mind, that the ports must be pubilshed by the other containers to the host via ports or expose, or add them to the network | ||
| + | # e.g. pcserver: | ||
| + | #Do NOT use networkmode: | ||
| # network_mode: | # network_mode: | ||
| - | # set / | ||
| - | # net.ipv4.ip_unprivileged_port_start = 80 | ||
| - | # net.ipv4.ip_unprivileged_port_start = 443 | ||
| - | # can also be set without booting: sysctl key = value | ||
| ports: | ports: | ||
| - " | - " | ||
| Zeile 74: | Zeile 61: | ||
| volumes: | volumes: | ||
| caddy_data: | caddy_data: | ||
| - | driver: local | ||
| - | driver_opts: | ||
| - | device: "" | ||
| - | type: "" | ||
| - | o: " | ||
| caddy_config: | caddy_config: | ||
| - | driver: local | ||
| - | driver_opts: | ||
| - | device: "" | ||
| - | type: "" | ||
| - | o: " | ||
| caddy_certs: | caddy_certs: | ||
| - | driver: local | ||
| - | driver_opts: | ||
| - | device: "" | ||
| - | type: "" | ||
| - | o: " | ||
| caddy_sites: | caddy_sites: | ||
| - | driver: local | + | |
| - | | + | networks: |
| - | | + | # Still needs to be defined while without it won't enable ipv6 |
| - | type: "" | + | default: |
| - | o: " | + | |
| + | | ||
| </ | </ | ||
| - | Also, check that your Firewall has those Ports open on your hosts and that Port Forwarding in your Router is enabled for ipv4 and for ipv6 that the host+ports are not blocked. | + | Also, check that your Firewall has those Port 80 + 443 open on your host and that Port Forwarding in your Router is enabled for ipv4 and for ipv6. |
| Zeile 107: | Zeile 80: | ||
| if you omit the Caddyfile, the server will already work, but we can directly Skip those tests and create the file '' | if you omit the Caddyfile, the server will already work, but we can directly Skip those tests and create the file '' | ||
| < | < | ||
| + | |||
| https:// | https:// | ||
| header Strict-Transport-Security max-age=31536000; | header Strict-Transport-Security max-age=31536000; | ||
| Zeile 114: | Zeile 88: | ||
| </ | </ | ||
| - | replace mylocalhostname with your actual hostname (can be found out by calling hostname in your terminal). | + | replace |
| Don't use localhost - see above. If you do not have a clue which hostname you have, better specify some fixed one which you can freely chose and edit ''/ | Don't use localhost - see above. If you do not have a clue which hostname you have, better specify some fixed one which you can freely chose and edit ''/ | ||
| Zeile 121: | Zeile 95: | ||
| Thats all - use '' | Thats all - use '' | ||
| - | You now have a powerful proxy, that can transparently deliver your Dockers to the world with SSL- encryption enabled. | + | If the Caddy doe not return any Errors, you now have a powerful proxy, that can transparently deliver your Dockers to the world with SSL- encryption enabled. |
content/serverbasics/docker-caddy.1705092100.txt.gz · Zuletzt geändert: von obel1x
