5

I am on Ubuntu 16.04 with the latest NGINX installed from their official repository:

$ sudo nginx -v nginx version: nginx/1.11.8 

I have the following defined in /etc/nginx/sites-available/greendot.conf:

# local dnsmasq resolver 127.0.0.1; map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream websocket { zone elixr 64k; server greendot-elixr-1:4000 resolve; server greendot-elixr-2:4000 resolve; } server { listen 4000; location / { proxy_pass http://websocket; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; } } 

I have followed the documentation on setting up DNS resolved upstream servers, and yet this configuration fails:

$ sudo nginx -T nginx: [emerg] invalid parameter "resolve" in /etc/nginx/sites-enabled/greendot-nginx.conf:11 nginx: configuration file /etc/nginx/nginx.conf test failed 

My goal is to simply create a server which uses DNS to periodically resolve its members. What am I doing wrong?

2
  • 8
    Additionally, the following parameters are available as part of our *commercial subscription:* Commented Jan 19, 2017 at 20:04
  • Ugh, didn't catch that, my bad. Commented Jan 19, 2017 at 20:14

1 Answer 1

1

The resolve parameter is part of nginx's commercial offering.

Here's the approach I ended up using:

server { ... # Use docker's internal nameserver resolver 127.0.0.11 valid=10s ipv6=off; location / { set $target myproject-web; proxy_pass http://$target:8000; } } 

Note that:

  • You have to define a variable (like $target), or nginx will query once, and use the resulting IP(s) forever (ignoring the resolver's 'valid' parameter).
  • If the DNS query returns several IPs; nginx will round-robin to them.
  • This approach may not work for you if you have more complex upstream requirements (backup endpoints, etc).
1
  • 1
    Just FYI, right now using mainline nginx (v1.27.3+) you can get this feature working without commercial license. Weirdly enough, I was required to configure a shared memory zone in the upstream block. Commented Feb 17 at 2:00

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.