load_module modules/ngx_stream_module.so;
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
stream {
log_format main '$remote_addr [$time_local] $protocol $status $bytes_sent $bytes_received $session_time';
access_log /var/log/nginx/access.log main;
upstream my-tcp-app {
server my-tcp-app:9000;
}
server {
listen 9000 so_keepalive=on;
proxy_pass my-tcp-app;
}
}
docker run --detach --name nginx-tcp-proxy \
--volume "${PWD}/tcp-proxy.conf:/etc/nginx/nginx.conf" \
--publish "9000:9000" \
--workdir "/usr/share/nginx/" \
nginx
telnet localhost 9000
docker stop nginx-tcp-proxy
docker rm nginx-tcp-proxy