Layer4 SRV proxy

1. Caddy version (caddy version):

v2.4.3 xcaddy built from GitHub - mholt/caddy-l4: Layer 4 (TCP/UDP) app for Caddy

2. How I run Caddy:

caddy is running as a service on a vpc instance behind a load balancer that has passtrough.
I use json configuration with a apps > http > static_response handler for healthcheck beside the layer4 that I’m trying to configure

d. My complete Caddyfile or JSON config:

omitted logging and http app. since this is working fine.

"apps": {
    "layer4": {
      "servers": {
        "server0": {
          "listen": ["0.0.0.0:443"],
          "routes": [
						{
							"handle": [
								{
									"handler": "proxy",
									"upstreams": [
										{"dial": ["myname.dhru3k.mongodb.net:27017"]}
									]
								}
							]
						}            
          ]
        }
      }
    }
}

3. The problem I’m having:

I don’t have access to port 27017 so I’m trying to use caddy as a proxy on port 443 so it redirects traffic to destination on port 27017.

The destination is a database url like so:
mongodb+srv://username:password@myname.dhru3k.mongodb.net/testing?somequery=true&otherquery=yep

[My Client] => [mydomain:443] => [mongodb.net:27017]

The client is complaining about resolving DNS, probably this “+srv”, so, before I go on, I would like to know if what I’m trying to achieve is possible with caddy.

I’m kinda confused. Why are you using a +srv address? Do you have a DNS server that will resolve SRV records? If not, then yeah, you should probably remove +srv from the address.

Also, the address doesn’t seem to specify port 443, so it might be trying 27017 by default (i.e. mongodb’s default)? I don’t know how your client works so I don’t know what it would assume as the port.

Other than that, I’m not really seeing any other problems here, you haven’t posted any logs or anything else that would indicate a problem. Please completely fill out the help topic template next time.

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