Caddy on Docker (Portainer) to allow HTTPS for VaultWarden

1. Caddy version (caddy version):

Caddy V2.4.6 (docker)

2. How I run Caddy:

Caddy is installed on Docker (Portainer), on a local network (ubuntu-server).

a. System environment:

  • Hardware is a NUC running Proxmox
  • Caddy is installed on an ubuntu VM running Docker.
  • VaultWarden is installed as a separate container in Docker too.

I have a separate RasperryPi running PiHole

b. Command:

Run from Portainer with the following:
CMD = caddy run --config /etc/caddy/Caddyfile --adapter caddyfile
Volumes:
/var/lib/docker/volumes/caddy/config >> /config
/var/lib/docker/volumes/caddy/data >> /data
/var/lib/docker/volumes/caddy/Caddyfile| >> /etc/caddy/Caddyfile
/var/lib/docker/volumes/caddy/site >> /usr/share/caddy

Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

have tried:

vault.ubuntu-server {
reverse_proxy localhost:8000
}

and also tried:

vault.localhost {
reverse_proxy localhost:8000
}

Paste config here, replacing this text.
Use `caddy fmt` to make it readable.
DO NOT REDACT anything except credentials.
LEAVE DOMAIN NAMES INTACT.
Make sure the backticks stay on their own lines.

3. The problem Iā€™m having:

I am unable to have Caddy serve VaultWarden as HTTPS. VaultWarden is on the same server, using port 8000 mapped to 80 in Portainer. VaultWarden opens ok, but I need to enable SSL to be able to set-up and continue

4. Error messages and/or full log output:

No errors as such. Just canā€™t get Caddy to work with this set-up

5. What I already tried:

I have tried several CaddyFile options.

6. Links to relevant resources:

Caddy will have logs. Check the containerā€™s log outputs.

Did you bind Caddy to ports 80 and 443 on the host machine?

Do you have your local DNS server (I assume pihole) resolving that hostname to the IP address of your server?

I canā€™t suggest anything without actually seeing evidence of the errors. Check your logs, explain whatā€™s not working. Make a request with curl -v to show what happens.

And please place your logs and config within code blocks in your post, between the lines with ``` backticks. Code blocks will makes sure formatting is preserved. Itā€™s hard to read otherwise. (Also see the help topic template, you were meant to paste your logs within those code fences where it says ā€œPaste config hereā€)

Hi - thank you Francis for responding.

I think that Caddy is kind of working but I donā€™t think the CaddyFile is correct. Yes, I bind ports 80 and 443 on the host machine. Yes, the local DNS is Pi-hole and this is resolving back to the Caddy server.

The issue is that Chrome is saying the connection is Not Secure when connecting both internally (with Pihole DNS forwarding to Caddy) or externally (where the web-server A Host points to Caddy IP).

This is an example of the CaddyFile where ā€˜serviceā€™ is accessible from within the network (local.lan) and externally (example.com):

{
local_certs
}
service.local.lan {
reverse_proxy 192.168.X.Y:8000
}
service.example.com {
reverse_proxy 192.168.X.Y:8000
}

But in both cases, I get Not Secure. I think that this is issuing local certs in both cases, so need to only issue local certs to the local version (local.lan) and not to external. But, not sure how do do this within the CaddyFile.

Right, the local_certs global option just makes Caddy issue local certs for all sites regardless of whether itā€™s a public domain or not. Itā€™s more meant as a quick switch to flip when testing things to avoid hitting public ACME issuers.

Instead, you should use the tls internal directive on any sites you want to use local certs.

As I said, please use backticks for code blocks when posting config or logs. Whitespace gets lost otherwise, making it harder to read.

You used block quotes. Use code blocks, which involves putting 3 backticks on the lines immediately preceding and following the logs/config.

it ends up looking like this

Thereā€™s also a button in the reply editor that looks like </>

Thatā€™s strange, but harmless.

I tried to load https://vault.dsewell.co.uk myself, and it seems to work fine (HTTPS, with a valid publicly trusted cert). So you should be good to go.

1 Like

Thank you for your help :slight_smile: :grin:

Sorry for the very poor use of markup :frowning:

2 Likes

This topic was automatically closed after 30 days. New replies are no longer allowed.