#1081 closed enhancement (invalid)
ngx_stream_core_module proxy_pass dynamic resolve
Reported by: | Watson Yim | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | |
Component: | nginx-module | Version: | 1.11.x |
Keywords: | proxy_pass, ngx_stream_core_module, stream, tcp | Cc: | |
uname -a: | Linux ip-10-0-1-98 4.4.11-23.53.amzn1.x86_64 #1 SMP Wed Jun 1 22:22:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux | ||
nginx -V: |
nginx version: nginx/1.11.4
built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) built with OpenSSL 1.0.1k-fips 8 Jan 2015 TLS SNI support enabled configure arguments: --user=nginx --group=nginx --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --with-http_ssl_module --with-pcre --with-http_stub_status_module --with-http_realip_module --with-stream |
Description
Hi NGINX team,
Awesome work with the TCP reverse proxy! Keep it up!
I have a use case where my proxy_pass destination needs DNS re-resolving every day or so. I did some testing and was unable to setup destination re-resolving. My config is as follows:
/etc/nginx.conf
stream {
resolver 10.0.0.2 valid=10s;
resolver_timeout 10s;
include /etc/nginx/stream.d/*.conf;
}
/etc/nginx/stream.d/tcpbackend.conf is a symlink to /etc/nginx/stream.sites/tcpbackend.conf
/etc/nginx/stream.sites/tcpbackend.conf
server {
listen 1883;
proxy_pass internal-app.example.com:1883;
}
This setup works (as in tcp is successfully routed to the A host at internal-app.example.com, but when there is an A host change, nginx continues to route to the old IP.
This fix is readily available in the http module using "set $be internal-app.example.com" and then "proxy_pass $be". Is there such thing possible for the stream module?
Thanks!
Change History (2)
comment:1 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 8 years ago
Hi mdounin,
Thanks for your help! map did the job. In case anyone is interested, below is the code I used that got it to work:
in /etc/nginx/stream.sites/tcpbackend.conf:
map internal-app.example.com $be {
default "internal-app.example.com";
}
server {
listen 1883;
proxy_pass $be:1883;
}
Thanks again!
In stream, there is no
set
directive, but there are other ways to create variables, including map.Please use mailing list for further questions. Thank you.