Nginx TCP stream routing based on source IP
You can use a directive map
for this behavior. Something like this (untested).
upstream staging1 {
server 1.2.3.4:8000;
}
upstream staging2 {
server 1.2.3.44:8000;
}
map $remote_addr $upstream {
4.5.6.7 staging2;
default staging1;
}
stream {
server {
listen 8000;
proxy_pass $upstream;
}
}