Welcome! Log In Create A New Profile

Advanced

NGINX TCP Proxy and Session Persistence

Posted by ronst3r 
NGINX TCP Proxy and Session Persistence
September 29, 2022 12:03PM
Hi there fellow forum members!

I have a bit of a fringe case and I'm hoping that perhaps someone has faed this scenario before.

I currently have an Nginx TCP proxy configured that receives SSH connections from a client and then proxies it to a remote host.

CLIENT_APP (SSH) -> NGINX_PROX -> REMOTE_SSH_HOST

This is easily enough achieved with the use of Nginx's TCP Stream module.

However, for every connection from the client, Nginx will initiate a new connection to the remote host.
Is there any way for Nginx to create a persistent connection for the each client connection so that in the event of the client temporarily losing connection, when re-established connectivity, the previous session to the Remote Host gets re-utilised ?

#Config:

stream {

upstream remote_ssh_server {

server REMOTE_HOST_1:22;

server REMOTE_HOST_2:22;

}

server {

listen 9999;

proxy_pass remote_ssh_server;
proxy_socket_keepalive on;
proxy_buffer_size 16k;
proxy_timeout 1800s;
proxy_connect_timeout 1800s;

}
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 276
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready