Score:1

Nginx -- Can't use mDNS domain name in upstream server

br flag

Minimal example

Machine A and B, where B uses mDNS with domain name b.local and set ssh service at port 2222. A and B does not turn on firewall.

In machine A's nginx.conf:

stream {
    upstream b-ssh {
        server  b.local:2222;
    }
    server {
        listen      2222;
        listen      [::]:2222;
        proxy_pass  b-ssh;
    }
}

When using nginx -t to test this configuration on machine A, error occurred:

[emerg] host not found in upstream "b.local:2222"

However, in machine A, using ssh -p 2222 b.local works normally (-4 or -6 is also tested)

Possibly useful infos

In my real-world example, machine A is a Windows 11 which disables all firewalls; machine B is WSL2 ubuntu 21.10 inside machine A which uses avahi-daemon mDNS service.

In side machine A's nginx.conf, I also set an HTTP proxy pass:

http {
    server {
        listen  8929;
        listen  [::]:8929;
        location / {
            proxy_pass  http://b.local:8929;
        }
    }
}

and this works well even though this uses mDNS domain name.

If I replace mDNS domain name with its real IP in upstream server, the SSH proxy works.

Score:0
bd flag

Install libnss-mdns and make sure there's an entry for mdns in /etc/nsswitch.conf:

hosts:          files mdns [NOTFOUND=return] dns

You can test mdns resolution with getent:

getent hosts b
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.