Nginx, resolver directive: how-to?

I see what you’re asking, you want to create a DNS name for the LXD DNS resolver.

You can do this using the raw.dnsmasq setting on the network config, e.g.

# Get address of lxdbr0 DNS server.
lxc network get lxdbr0 ipv4.address
10.102.242.1/24
# Add this as a DNS name in dnsmasq itself.
lxc network set lxdbr0 raw.dnsmasq="address=/gateway.lxd/10.102.242.1"

Now in a container:

lxc exec c1 -- ping -c1 gateway.lxd
PING gateway.lxd (10.102.242.1) 56(84) bytes of data.
64 bytes from 10.102.242.1 (10.102.242.1): icmp_seq=1 ttl=64 time=0.035 ms

--- gateway.lxd ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.035/0.035/0.035/0.000 ms

p.s. nginx does appear to resolve the address of gateway.lxd at startup when used in the resolver directive. However I do not know whether it will re-resolve that address periodically so if it does ever change you may need to restart nginx.