本文共 1366 字,大约阅读时间需要 4 分钟。
wget http://nginx.org/download/nginx-1.14.0.tar.gztar -xzf nginx-1.14.0.tar.gzcd nginx-1.14.0
Debian 环境需要安装的软件包
apt install gcc makeapt install libpcre3 libpcre3-dev //【正则表达式库】 官网http://www.pcre.org/apt install openssl libssl-dev //【openssl库】 官网https://www.openssl.org/apt install zlib1g-dev
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-file-aio --with-streammake && make install
vim /usr/local/nginx/conf/nginx.conf
配置是ip和端口是需要代理的地址端口,listen的端口是提供给外部用来访问的端口worker_processes 1;events { worker_connections 1024;}stream { upstream tcp_proxy { hash $remote_addr consistent; #远程地址做个hash server 192.168.230.131:22; } server { listen 2222; proxy_connect_timeout 1s; proxy_timeout 36000s; #后端连接超时时间 proxy_pass tcp_proxy; } }
/usr/local/nginx/sbin/nginx
查看端口映射
netstat -ntpl|grep 2222tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 13661/nginx: master
测试远程ssh访问
ssh -p 2222 th@10.95.42.136th@10.95.42.136's password: Last login: Sat Apr 8 22:32:14 2017 from linux-node1[root@linux-node2 ~]# lstest.txt
错误日志
./sbin/nginx nginx: [emerg] getpwnam("www") failed
解决方法,添加www用户
groupadd -f wwwuseradd -g www www
转载地址:http://llfli.baihongyu.com/