Missing port in address when using lookup_srv

1. Caddy version (V2.1):

2. How I run Caddy:

I'm running caddy in Docker on alpine from a simple run command, im configuring it using the API from a nodejs app, using axios.

a. System environment:

Docker Alpine 3.1

b. Command:

docker run -d -p 8080:80 -p 9999:9999 --network my-net

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

const sta = {
  admin: {
    listen: "0.0.0.0:9999",
  },
  logging: {},
  apps: {
    http: {
      servers: {
        example: {
          listen: [":80"],
          routes: [
            {
              match: [{ path: ["/main"] }],
              handle: [
                {
                  body: "Hello, world!",
                  handler: "static_response",
                },
              ],
            },
            {
              match: [{ path: ["/other"] }],
              handle: [
                {
                  handler: "reverse_proxy",
                  transport: {
                    protocol: "http",
                    tls: {
                      insecure_skip_verify: true,
                      server_name: "node-express1",
                    },
                  },
                  upstreams: [
                    { lookup_srv: "http://node-express1:8522" },
                  ],
                },
              ],
            },
          ],
        },
        logs: {},
      },
    },
  },
};

3. The problem Iā€™m having:

In the documentation it says, ā€œIf DNS SRV records are used for service discovery with this upstream, specify the DNS name for which to look up SRV records here, instead of specifying a dial address.ā€

I want to use the docker name of my container , in this case node-express1, but if i put that in the looup_svr variable it give an error saying the port is missing, it seems if i donā€™t include the dial variable it will not take the config and gives the port missing error. If i put anything in dial itā€™ll take the config but wont work. I also cant get logging to work, i followed the forum suggestion and added logs:{}, but it doesnt return anything when i curl it.

I can get a response from the node-express1 container via hostname from the caddy container command line.

4. Error messages and/or full log output:

loading config: loading new config: loading http app module: provision http: server example: setting up route handlers: route 1: loading handler modules: position 0: loading module 'reverse_proxy': provision http.handlers.reverse_proxy: missing port in address

5. What I already tried:

I have tried adding the transport section i found someone else suggesting was the problem, that didnā€™t help, Iā€™ve tried putting dial:ā€œ:8852ā€ in to give it a port, that will allow the config to load but it doesnā€™t work. I cant really think what else to try and without logging its hard to know what to do.

Incidentally i know i shouldā€™nt(and wont) be exposing my admin port, but its easier to upload configs from my machine to docker with it open and i can keep track of the million confings ive tried.

this is the command i used to try and get the logs

 curl localhost:9999/config/apps/http/servers/example/logs/ -X POST -H "Content-Type: application/json" -d '{}'

it just returns nothing

6. Links to relevant resources:

Tried this

tried this to get loggin working, didnt work

Unfortuately itā€™s a known issue, but thereā€™s a fix in the works:

https://github.com/caddyserver/caddy/pull/3756

Thanks for your reply, Sorry I didnā€™t find the bug post myself. I tend to assume itā€™s my mistake rather than a bug.

1 Like

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