Configuration of Nginx TCP proxy service in windows

Nginx is not only used as web proxy server(support http and https protocol), it’s also can be used as regular TCP proxy server,supporting any TCP port, such as TCP 3306, 3690, 3389, 22 and so on.

It can realize the following feature. Client isn’t able to access source server A and source server B directly, but Server C can. we configure proxy service on server C, Thus client can visit server A and server B through proxy service on server C.

In this passage, I’ll introduce configuraton of nginx TCP proxy service briefly.

NGINX version

nginx/1.13.3

Complied parameter


TLS SNI support enabled
configure arguments: –with-cc=cl \
–builddir=objs.msvc8 \
–with-debug \
–prefix= \
–conf-path=conf/nginx.conf \
–pid-path=logs/nginx.pid \
–http-log-path=logs/access.log \
–error-log-path=logs/error.log \
–sbin-path=nginx.exe \
–http-client-body-temp-path=temp/client_body_temp \
–http-proxy-temp-path=temp/proxy_temp \
–http-fastcgi-temp-path=temp/fastcgi_temp \
–http-scgi-temp-path=temp/scgi_temp \
–http-uwsgi-temp-path=temp/uwsgi_temp \
–with-cc-opt=-DFD_SETSIZE=1024 \
–with-pcre=objs.msvc8/lib/pcre-8.40 \
–with-zlib=objs.msvc8/lib/zlib-1.2.11 \
–with-select_module \
–with-http_v2_module \
–with-http_realip_module \
–with-http_addition_module \
–with-http_sub_module \
–with-http_dav_module \
–with-http_stub_status_module \
–with-http_flv_module \
–with-http_mp4_module \
–with-http_gunzip_module \
–with-http_gzip_static_module \
–with-http_auth_request_module \
–with-http_random_index_module \
–with-http_secure_link_module \
–with-http_slice_module \
–with-mail \
–with-stream \
–with-openssl=objs.msvc8/lib/openssl-1.0.2l \
–with-openssl-opt=no-asm \
–with-http_ssl_module \
–with-mail_ssl_module \
–with-stream_ssl_module

Parameter of nginx.conf


user nobody;
worker_processes 2;
events {
worker_connections 1024;
}
stream {
include vhost/*.conf;
upstream mofnet {
server IP_A:PORT_A;
}
upstream mojnet {
server IP_B:PORT_B;
}
}

Parameter of HOST A


server {
listen PORT_C;
proxy_pass IP_A;
}

Parameter of HOST B


server {
listen PORT_D;
proxy_pass IP_B;
}

Leave a Reply