Install Nginx with stream module:
sudo apt install nginx-full
The output of the command
nginx -V
should contain with-stream=dynamic.
And add the following to /etc/nginx/nginx.conf:
stream {
server {
listen 12345; # The port that Nginx listens to
proxy_pass 192.168.0.121:389; # Where to forward connections
}
}

