UDP forwarding with nginx
So this did seem to be the solution (in my note above).
If using my example from above, you want this to look like:
stream {
server {
listen 11016 udp;
proxy_pass juniper_close_stream_backend;
proxy_responses 0;
}
}
This tells nginx not to expect a response, which it shouldn't need from UDP. I don't know why their examples don't show this when discussing DNS, which can be entirely UDP driven.
Differentiate between source address of udp packets
Managed to solve it by using a map. Updated config is now
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
stream {
#define the various upstreams
upstream app_1 {
server 127.0.0.1:5678;
}
upstream app_2 {
server 127.0.0.1:9000;
}
#map source port to upstream
map $remote_port $backend_svr {
1234 "app_1";
1235 "app_2";
}
#all udp traffic received on 8000, depending on source it will be redirected
server {
listen 8000 udp;
proxy_pass $backend_svr;
}
}
Is it possible to forward NON-http connecting request to some other port in nginx?
It is possible since nginx 1.9.0:
http://nginx.org/en/docs/stream/ngx_stream_core_module.html
Something along these lines (this goes on top level of nginx.conf
):
stream {
upstream backend {
server backend1.example.com:12345;
}
server {
listen 12345;
proxy_pass backend;
}
}
Related Topics
How to Highlight The Differences Between Subsequent Lines in a File
How to Use/Learn Video4Linux2 (On Screen Display) Output APIs
How to Add a Custom System Call on X86 Ubuntu Linux
How to Connect to Sftp Using Linux Command from Perl
How to Install Packages in Tcl
Socket Send Concurrency Guarantees
Show Image Notification from Bash Script
Bash-Script Printing a PDF to a PDF in Linux
Why Can One Remove/Rename Open Files in Linux
Run Shell Script After Xserver Is Started
Ack & Negative Lookahead Giving Errors
Error Hh604: Error Running JSON-Rpc Server: Error:0308010C:Digital Envelope Routines::Unsupported
Docker Container Size Much Greater Than Actual Size
Which Is The Correct Way to Register a New Net_Device
Gunicorn Does Not Start After Boot
Incomplete Lsb Comment. Insserv: Missing Valid Name for 'Provides:' Please Add