18

I'm trying to host a vaultwarden instance through docker and failing miserably. This isn't my first attempt either but I've got much further than before.

I'm using a DuckDNS domain with caddy as reverse proxy, but it appears that the domain is defaulting to port 80 no matter how I set up the config. I can't specify a port number in DuckDNS as far as I can tell. If the simple solution is to just buy a domain name I will consider it. Otherwise could really use some help in sorting out why it's not connecting.

I can't access Vaultwarden on the internal IP as it's not being served as SSL but both Vaultwarden and Caddy are running with no errors in logs. I've left out a bunch of admin env variables for the Vaultwarden service to truncate the code.

docker-compose:

`[___](services:

vaultwarden:

container_name: vaultwarden

image: vaultwarden/server:latest

restart: unless-stopped

ports:

  - 11808:80

  - 11443:443

volumes:

  - ./data/:/data/

environment:

  - ROCKET_PORT=11444

caddy:

image: caddy:2

container_name: caddy2

restart: always

ports:

  - 1808:11808

  - 1443:11443

volumes:

  - ./caddy:/usr/bin/caddy

  - ./Caddyfile:/etc/caddy/Caddyfile:ro

  - ./caddy-config:/config

  - ./caddy-data:/data

environment:

  DOMAIN: "https://example.duckdns.org"

  EMAIL: "example@domain.com"
        
  DUCKDNS_TOKEN: "token"

  LOG_FILE: "/data/access.log")`

Caddyfile:

' {$DOMAIN}:1443 {

log {

level INFO

output file {$LOG_FILE} {

  roll_size 10MB

  roll_keep 10

}

}

tls {

dns duckdns {$DUCKDNS_TOKEN}

}

encode gzip

Notifications redirected to the WebSocket server

reverse_proxy /notifications/hub vaultwarden:3012

Proxy everything else to Rocket

reverse_proxy vaultwarden:11444

}`

Any idea where I'm going wrong?

you are viewing a single comment's thread
view the rest of the comments
[-] terraborra@lemmy.nz 3 points 4 days ago

I should have said in the main text, I have something else on port 80 and I though best practice was not to expose 80 or 443?

[-] NegativeLookBehind@lemmy.world 4 points 4 days ago

Map host port 8080 to container port 80. 8443 to 443.

[-] lorentz@feddit.it 1 points 3 days ago

You can configure caddy to use 80 and be a reverse proxy for both the services, serving one site or the other depending on the name (you will need a second DNS entry pointing to the same IP). about not exposing 443, I really doubt that caddy can automatically retrieve SSL certificates for you if not running on the default port. Check the documentation, if I'm right either you open an empty website on 443 just for the sake of getting SSL certs to run https, and manually configure the other port to do the same, or you get the certificates manually using the DNS verification (check let's encrypt documentation) and configure caddy to use them.

[-] just_another_person@lemmy.world -2 points 4 days ago* (last edited 4 days ago)

If you don't want to expose port 80 or 443, then just change the ports they are running on. Right now you're mapping 80/443 in docker, so just change those numbers to something else if you don't want to use them. The number on the right is the internal service port, and the left of the colon is the port you're opening to proxy to the port on the left. Adding Caddy does exactly the same thing and serves no purpose except another layer of obfuscation you don't need.

this post was submitted on 05 Jan 2025
18 points (90.9% liked)

Selfhosted

40956 readers
862 users here now

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don't control.

Rules:

  1. Be civil: we're here to support and learn from one another. Insults won't be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it's not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don't duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

founded 2 years ago
MODERATORS