Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help] Postgres DB behind caddy-docker-proxy #680

Open
accforgithubtest opened this issue Dec 13, 2024 · 5 comments
Open

[Help] Postgres DB behind caddy-docker-proxy #680

accforgithubtest opened this issue Dec 13, 2024 · 5 comments

Comments

@accforgithubtest
Copy link

I am seeking help to get postgres running behind caddy-docker-proxy.
Is it possible to host the postgres db behind caddy docker proxy, especially without opening the ports on the docker host ?

I currently have pihole redirecting local.host to the ip address of docker host.
Postgres, pihole, caddy-docker-proxy are all set up via docker compose, on the same default bridge network, with ipv6 disabled.
This set-up is working for the most part, except for the reverse proxying using caddy-docker-proxy.

I tried using dbeaver to connect to postgres -

  1. Without exposing the host port, using the url - jdbc:postgresql://postgres.local.host/root and get connection refused even when I pass the user credentials on the UI. No logs on both postgres and caddy-docker-proxy container logs.
  2. If I enable the host ports, then I am able to connect via jdbc:postgresql://local.host:5432/root using the user credentials on the UI.
    This means even though I have added the below labels to postgres container, it doesn't seem to be doing the reverse proxying.

Am i missing any additional labels needed for a database reverse proxying ?
TIA to anyone who can share a working docker compose set up for postgres behind caddy-docker-proxy.

services:
  postgres:
    image: postgres:
    # ports:
      # - ${port_host_postgres}:5432
    labels:
      - caddy=postgres.local.host
      - caddy.reverse_proxy={{upstreams 5432}}
    volumes:
    ...
    ...
@lucaslorentz
Copy link
Owner

Caddy by default is an HTTP(s) (layer 7) server/reverse proxy.
As far as I know, postgres doesn't connect via HTTP connection.
You would need an additional plugin like caddy-l4, and you should be able to configure it with CDP labels as well.
Search CDP issues for "layer 4," "caddy-l4," and "TCP," and you will find some discussions and examples.

@lucaslorentz
Copy link
Owner

lucaslorentz commented Dec 13, 2024

Maybe this is the only discussion where someone claimed to get it working: #236

The main challenge at the moment is that it is impossible to write IP addresses in key of of a docker label because dot means nesting, and we don't support escaping it. But doing it without IP, just with port might work.

@accforgithubtest
Copy link
Author

Thank you @lucaslorentz - I will check that discussion out.
Appreciate you pointing me in the right direction.

@Rizary
Copy link

Rizary commented Dec 26, 2024

@accforgithubtest have you make it worked?

@accforgithubtest
Copy link
Author

@Rizary - Not yet unfortunately.
I need to upgrade to caddy 2.8.4 according to that discussion, however a different issue with sablier is preventing me from upgrading to 2.8.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants