Cloudflared Tunnel + Caddy for couchdb

1. The problem I’m having:

I am running couchdb on raspberry pi and can be access locally using http://192.168.0.103:5984 I have also setup a cloudflared tunnel using subdomain https://couchdb.example.com so it works well and can be accessed both externally and internally networks. However I want that if I am inside the network then it shouldn’t goto the cloudflared tunnel and directly goto the server. I have configured my pihole and pointed the https://couchdb.example.com to goto 192.168.0.103.

I am also running a caddy instance on docker using the following

services:
  caddy:
    image: caddy:latest
    container_name: customcaddy
    volumes:
      - /home/pi/data/customcaddy/Caddyfile:/etc/caddy/Caddyfile # Map the Caddyfile from host to container
      - /home/pi/data/customcaddy/caddy_data:/data                 # Persist data files like SSL certificates
      - /home/pi/data/customcaddy/caddy_config:/config             # Persist configuration data
    ports:
      - "3135:80"    # Map port 80 on the container to port 8080 on the host
      - "3136:443"   # Map port 443 on the container to port 8443 on the host
    restart: unless-stopped

volumes:
  caddy_data:   # Define the named volume for data persistence
  caddy_config: # Define the named volume for configuration persistence

this is how my caddyfile looks like

couchdb.example.com {
    reverse_proxy http://192.168.0.103:5984
}

With these settings when I visit couchdb.example.com I am taken to the apache2 default page.

What am I doing wrong ??

Show an example request with curl -v, seeing the response headers would give a clue as to what’s going on.

Also, enable the debug global option and share your Caddy logs, which will show what Caddy is doing.

You’re binding different ports on the host. Do you have Apache running on that machine on ports 80/443? If so, turn off apache and change Caddy to use ports 80/443 on the host.

1 Like

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