首先我们会用到nginx
下载nginx
http://nginx.org/en/download.html
里面会有选择nginx版本,任意nginx都可以
apt install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel open openssl-devel
这一步可有可无,实际操作无所谓,毕竟不开网页嘛
tar xf nginx-
nginx-后面看版本号用tab补全。
进入nginx目录
./configure --with-stream --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --without-http_rewrite_module --without-http_gzip_module
make
make install
等待安装完成后
在/usr/local/nginx/conf/nginx.conf末尾追加
stream {
server {
listen 12345; #此处是你想要的端口号
proxy_pass db;
}
upstream db {
server 0.0.0.0:端口; #此处是你想反向代理的服务器
}
}
然后启动nginx即可