How to forward the external IP address to the port

1. Caddy version (caddy version):

v2.1.1

2. How I run Caddy:

I am running caddy on a raspberry Pi and on boot, “caddy start” runs.

a. System environment:

Raspberry OS Lite 32bit on a Raspberry Pi 4.

b. Command:

nano Caddyfile

d. My complete Caddyfile or JSON config:

mydomain.com {
       reverse_proxy * 192.168.1.1
}

192.168.1.1 is the internal IP address of my server. On my server I am running an sql database. On my router I am forwarding all my 3306 ports to my server.

3. The problem I’m having:

The problem is when I am accessing my SQL database on my server via the domain using reverse proxy, the SQL database sees the inbound connection coming from my router’s IP address (192.168.0.1) instead of the actual external IP address from the computer off network that is trying to connect to my domain at port 3306.

5. What I already tried:

I looked up the X-Forwarded-For feature but not sure where to put it in my Caddyfile or how I can instruct this specific route to forward the external IP address instead.

SQL doesn’t use HTTP, so Caddy can’t be used (out of the box) to proxy traffic to it. SQL uses a raw TCP connection.

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