mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2026-02-05 00:29:40 +03:00
Question: How to set up Caddy? #162
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MeiRos on GitHub (Dec 17, 2018).
Hi everybody!
Bitwarden_rs is awesome and easy to set up, if people use the easy way.
When I only run Bitwarden_rs Docker image I didn't have any problems. Container was easy to set up. Now I want to use Caddy as reverse proxy on the same server. But nothing works. I have searched guides, info and stories, but none of them solve my problem. I have tryed different settings and results are: bad gateway, too many redirections or something is wrong with ssl connection. Can't get new certs with Caddy and I can't make old ones to work.
I think I have tryed all the possible configurations, even those which I knew won't work.
I have bw.domain.net with my Bitwarden_rs server's IP. Domain.net is with other server's IP. Can this cause problems with Caddy Docker image? With Certbot I didn't have problems.
I tryed to set Caddyfile like the example in the proxy file. Servers were localhost and 127.0.0.1. Both didn't work.
Can't say much about Caddyfile or parameters with docker run command, because I have tryed so many different sets.
If someone have similar setup or knowledge how this should work, some advice would be awesome.
Maybe I'm too tired to figure this out. It's already time to get ready for the night and bed.
@dani-garcia commented on GitHub (Dec 17, 2018):
My caddyfile is setup like this:
Both the proxy and the server are running in the same machine.
Because I have my domain behind cloudflare, I'm setting the HTTPS with the cloudflare plugin, but you can use the default option or another plugin (check https://caddyserver.com/docs/tls).
To test if the problem is obtaining the certificates, you can try using
tls self_signed, which would generate self-signed certificates.@ghost commented on GitHub (Dec 18, 2018):
@dani-garcia
I want to use Caddy as reverse proxy too but I don't have a public domain. I use Bitwarden only in my local network. What address should I use in your example instead of: "bw.mydomain.com"?
Should I use my BW server IP?
@MeiRos commented on GitHub (Dec 18, 2018):
Thanks that helped a bit. I got new certs. :)
But still no luck with proxy. Just 502 error.
curl -i localhost:8000 is working.
curl -i bw.domain.net is not. 502 bad gateway.
My Caddyfile is like above except tls my@email.com.
Caddy run command:
Bitwarden_rs run command:
I don't understand what is wrong. Some help is needed. Can you see what is wrong?
@dani-garcia commented on GitHub (Dec 18, 2018):
@Haxy I'm pretty sure that you can use your IP and port, yes.
@MeiRos Are you doing both curls from the same machine? Try changing the caddyfile to use localhost instead of 0.0.0.0, maybe it's not recognizing it. Otherwise, try setting caddy without tls enabled to see if that works.
@mrwulf commented on GitHub (Dec 19, 2018):
Or, if you really want a DNS name (or to test!), check out this site: http://nip.io/
You basically just use bw.<IP Address>.nip.io as the DNS name and it will get resolved back to <IP Address>
@MeiRos commented on GitHub (Dec 19, 2018):
@dani-garcia
I did curls on the same server where are Bitwarden_rs and Caddy.
Error.log with localhost in the caddyfile
Curl -Iv https://bw.domain.net (with 0.0.0.0)
Results are same with 'localhost' setting. Only numbers after 'easy handle' changes.
Ssl off
With Google I found this. https://github.com/mholt/caddy/issues/1944 Added bw.domain.net to hosts file. No help.
Still no working reverse proxy. Do you still have ideas to try? :)
@sitic commented on GitHub (Dec 19, 2018):
@MeiRos The problem is that localhost/127.0.0.1 inside the caddy docker container is not the IP of the host, but rather the local caddy container.
You either need to set the proxy target IP in the caddyfile to the local IP of the host (like 192.168. ...) and allow those connections with iptables/ufw, or (highly recommanded) use docker-compose.
See https://github.com/dani-garcia/bitwarden_rs/issues/126#issuecomment-417872681 for an docker-compose example, it will automatically create a local
docker networkwhich will allow the caddy and bitwarden_rs containers to talk to each other.@MeiRos commented on GitHub (Dec 20, 2018):
Thanks @sitic it was easy to setup with docker-compose. I thought it's easy to use 'docker run' too, but it needs more work than I can do.
@dani-garcia commented on GitHub (Jan 11, 2019):
I think this is solved by now and we can close it