Use Caddy as the reverse proxy

Hi, I've been trying to use my Caddy reverse proxy with Homarr, but I'm encountering a problem. Homarr starts using http://ca7dab43dd9f:7575 (Docker container ID) instead of 127.0.0.1 (localhost). This is my docker-compose.yml file:
services:
homarr:
container_name: homarr
image: ghcr.io/ajnart/homarr:latest
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock # Optional, only if you want docker integration
- ./configs:/app/data/configs
- ./icons:/app/public/icons
- ./data:/data
environment:
NODE_TLS_REJECT_UNAUTHORIZED: 0
BASE_URL: homarr.localhost
ports:
- 127.0.0.1:7575:7575
networks:
- reverse_proxy

networks:
reverse_proxy:
external: true
services:
homarr:
container_name: homarr
image: ghcr.io/ajnart/homarr:latest
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock # Optional, only if you want docker integration
- ./configs:/app/data/configs
- ./icons:/app/public/icons
- ./data:/data
environment:
NODE_TLS_REJECT_UNAUTHORIZED: 0
BASE_URL: homarr.localhost
ports:
- 127.0.0.1:7575:7575
networks:
- reverse_proxy

networks:
reverse_proxy:
external: true
I have the same exact setup using Homepage (https://github.com/gethomepage/homepage) as my personal dashboard for my homelab, and it's working fine. However, I would prefer to use Homarr because I find it nicer. 🙂 I have seen that Traefik works with Homarr. Will Caddy be supported someday? Do you know what might be wrong with my current setup? Thanks for the support!
GitHub
GitHub - gethomepage/homepage: A highly customizable homepage (or s...
A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations. - gethomepage/homepage
Solution:
I don't know what to write, and I'm not the best English writter 🙂 I have also done this on localhost, I think to use any domain it only require to change it in the Caddyfile homarr.mydomain.com for example. But I can't test this right now because I don't have any domain....
Jump to solution
16 Replies
Cakey Bot
Cakey Bot3mo ago
Thank you for submitting a support request. Depending on the volume of requests, our team should get in contact with you shortly.
⚠️ Please include the following details in your post or we may reject your request without further comment: - Log (See https://homarr.dev/docs/community/faq#how-do-i-open-the-console--log) - Operating system (Unraid, TrueNAS, Ubuntu, ...) - Exact Homarr version (eg. 0.15.0, not latest) - Configuration (eg. docker-compose, screenshot or similar. Use ``your-text`` to format) - Other relevant information (eg. your devices, your browser, ...)
❓ Frequently Asked Questions | Homarr documentation
Can I install Homarr on a Raspberry Pi?
Manicraft1001
Manicraft10013mo ago
Hi, the URL you see in the logs is just internal. It will & should not be used outside of the container. Apps don't implement "support for reverse proxies" - they should already work out of the box and your Caddy is likely misconfigured or doesn't forward the requests to Homarr. Have you looked into the proxy log? Any log entries in Homarr? Can you reach Homarr from Caddy?
adrinator8
adrinator83mo ago
First of all thanks for the explanation! And yes I have the logs, the message was too long so I didn't add it 🙂
{"level":"error","ts":1720465243.4753218,"logger":"http.log.error","msg":"dial tcp: lookup board on 127.0.0.11:53: no such host","request":{"remote_ip":"172.20.0.1","remote_port":"45718","client_ip":"172.20.0.1","proto":"HTTP/2.0","method":"GET","host":"homarr.localhost","uri":"/","headers":{"Sec-Gpc":["1"],"Sec-Fetch-Site":["none"],"Sec-Fetch-User":["?1"],"Cache-Control":["max-age=0"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"],"Sec-Fetch-Mode":["navigate"],"Sec-Ch-Ua":["\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Brave\";v=\"126\""],"Priority":["u=0, i"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Accept-Language":["en-US,en;q=0.9"],"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua-Mobile":["?0"]},"tls":{"resumed":true,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"homarr.localhost"}},"duration":1.247334037,"status":502,"err_id":"12py680zj","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
{"level":"error","ts":1720465243.4753218,"logger":"http.log.error","msg":"dial tcp: lookup board on 127.0.0.11:53: no such host","request":{"remote_ip":"172.20.0.1","remote_port":"45718","client_ip":"172.20.0.1","proto":"HTTP/2.0","method":"GET","host":"homarr.localhost","uri":"/","headers":{"Sec-Gpc":["1"],"Sec-Fetch-Site":["none"],"Sec-Fetch-User":["?1"],"Cache-Control":["max-age=0"],"Upgrade-Insecure-Requests":["1"],"User-Agent":["Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"],"Sec-Fetch-Mode":["navigate"],"Sec-Ch-Ua":["\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Brave\";v=\"126\""],"Priority":["u=0, i"],"Accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"],"Sec-Ch-Ua-Platform":["\"Linux\""],"Accept-Language":["en-US,en;q=0.9"],"Sec-Fetch-Dest":["document"],"Accept-Encoding":["gzip, deflate, br, zstd"],"Sec-Ch-Ua-Mobile":["?0"]},"tls":{"resumed":true,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"homarr.localhost"}},"duration":1.247334037,"status":502,"err_id":"12py680zj","err_trace":"reverseproxy.statusError (reverseproxy.go:1269)"}
Manicraft1001
Manicraft10013mo ago
"remote_ip":"172.20.0.1","remote_port":"45718" are you sure that you forward the requests to the correct port? By default, we expose to 7575 and you seem to do the same.
adrinator8
adrinator83mo ago
I have all the other containers with this setup and the only one is not working is this, this is because I thought was problem of how Homarr is starting. I have been looking at the Github repo too. Caddyfile: ... homarr.localhost { reverse_proxy homarr:7575 } ... I don't know what's wrong, I posted this here to see if somebody has the same error.
adrinator8
adrinator83mo ago
OMG, i don't know why but after restarting both containers it's working now... Thanks for your help, if you want I can share the whole setup to help people in the future. You can add it to the https://homarr.dev/docs/advanced/configuration/proxies-and-certificates
Manicraft1001
Manicraft10013mo ago
Yes, please do share it (contribute it to https://github.com/homarr-labs/documentation ). I'll mark this as resolved
GitHub
GitHub - homarr-labs/documentation
Contribute to homarr-labs/documentation development by creating an account on GitHub.
Solution
adrinator8
adrinator83mo ago
I don't know what to write, and I'm not the best English writter 🙂 I have also done this on localhost, I think to use any domain it only require to change it in the Caddyfile homarr.mydomain.com for example. But I can't test this right now because I don't have any domain.
adrinator8
adrinator83mo ago
For other people: You only have to put Caddyfile at the same folder as compose.yaml (or docker-compose.yml, both names are accepted). And run docker compose up -d and you are done 🙂 @Manicraft1001 If somebody can contribute this and do a better explanation to the documentation repository would be very nice.
Manicraft1001
Manicraft10013mo ago
Almost nobody in this server is native English speaker. We mostly are from Europe. I'd suggest you to try it anyway - all additions are reviewed by us before they go live. It's likely that simply nobody will pick it up otherwise.
adrinator8
adrinator83mo ago
Okay, I will try it tomorrow! I've never contributed in any repository. Do I need to clone the documentation repo, make a new branch. Do changes, do pnpm start and check if it's OK and then commit and push. Am I wrong? Tell me and I will do my best.
Manicraft1001
Manicraft10013mo ago
You need to fork (since you don't have permissions to push directly). You can close locally or make small adjustments directly via GitHub. It is recommended to quickly install dependencies using pnpm i and start the app with pnpm start. Then you can navigate to the page to check our your changes. After you're done, submit a PR and we'll give you feedback 🙂
adrinator8
adrinator83mo ago
Oh true, I forgot the fork 🙂 thanks! I'll be doing this as soon as I can. Good night!
adrinator8
adrinator83mo ago
I have done the Pull Request adding the Caddy setup to the documentation repository. I hope I've done it well 🙂 Tell me if you need anything more!
Want results from more Discord servers?
Add your server