#1220 closed defect (invalid)
Unable to config NGINX to re‑resolves a domain name for UDP / TCP
| Reported by: | Owned by: | ||
|---|---|---|---|
| Priority: | major | Milestone: | |
| Component: | nginx-core | Version: | 1.11.x |
| Keywords: | Cc: | jmcewan@… | |
| uname -a: | Linux servename 3.10.0-514.6.1.el7.x86_64 #1 SMP Wed Jan 18 13:06:36 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux | ||
| nginx -V: | nginx version: nginx/1.11.10 | ||
Description
According the docs, https://www.nginx.com/blog/dns-service-discovery-nginx-plus/ this is possible in the open source version.
The example is for the http block,
resolver 10.0.0.2 valid=10s;
server {
location / {
set $backend_servers backends.example.com;
proxy_pass http://$backend_servers:8080;
}
}
And according to the note following:
"Note: For TCP/UDP load balancing, this method of using a variable in the proxy_pass directive is supported in NGINX 1.11.3 and later, and NGINX Plus R10 and later."
But clearly not, as in 1.11.10 using set is not possible in a top level stream block. For example:
resolver 10.0.0.2 valid=10s;
server {
set $backend_servers backends.example.com;
listen 12345 udp;
proxy_pass $backend_servers:12345;
}
set will error as [emerg] "set" directive is not allowed here in /etc/nginx/nginx.conf:15
So either the document is wrong, or there's a bug where set should be supported but isn't.
Either way need to be able have the DNS re-resolve for TCP/UDP forwarding [given the dynamic nature of the destination IP].
Change History (6)
comment:1 by , 9 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
comment:2 by , 9 years ago
| Resolution: | invalid |
|---|---|
| Status: | closed → reopened |
Your answer is what I am telling you.
The doc's indicate you support a mechanism re-resolving DNS for UDP/TCP.
Looking in the mail list, there is the exact same question with the exact same problem.
[Oct 2016, no reasonable answer].
Clearly you do not support set.
Perhaps consider it as a feature request, if this is not possible.
comment:3 by , 9 years ago
You are wrong, dynamic name resolution (including re-resolving) is supported by the stream module when you use variables in proxy_pass. It is to be configured differently though, as there is no set directive. For example, you can use map to provide appropriate backend name:
stream {
resolver 127.0.0.1;
map $remote_addr $backend {
default foo.example.com;
}
server {
listen 12345;
proxy_pass $backend:12345;
}
}
As previously suggested, if you need help with configuring nginx, please consider support options available. No further clarification will be given here, sorry.
comment:4 by , 9 years ago
| Resolution: | → invalid |
|---|---|
| Status: | reopened → closed |
comment:5 by , 9 years ago
| Resolution: | invalid |
|---|---|
| Status: | closed → reopened |
Im happy to be wrong. Thought the map directive is only available in the http block.
ergo its scope doesn't apply.
hmm seems the docs are mix matched. I am wrong awesome.
http://nginx.org/en/docs/http/ngx_http_map_module.html
Syntax: map string $variable { ... }
Default: —
Context: http
thx.
comment:6 by , 9 years ago
| Resolution: | → invalid |
|---|---|
| Status: | reopened → closed |
As previously said, no further clarification will be given here. Please use the support options available.

There is no
setdirective in stream. You may provide variables forproxy_passby other means though, see docs.If you think that the blog post needs better clarification for the note in question, consider writing a comment to the blog post. If you need help with configuring nginx, consider using mailing list.