主机评测
nginx的tcp代理设置
[root@locahost ~]# yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel -y
[root@locahost ~]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@locahost ~]# tar xf nginx-1.12.2.tar.gz
[root@locahost ~]# cd nginx-1.12.2
[root@locahost nginx-1.12.2]# ./configure --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module --without-http
[root@locahost nginx-1.12.2]# make && make install
配置nginx.conf
[root@locahost nginx-1.12.2]# cd /usr/local/nginx/conf/
[root@locahost conf]# cp nginx.conf{,.bak}
[root@locahost conf]# vi nginx.conf
worker_processes auto;
error_log /usr/local/nginx/logs/error.log info;
events {
worker_connections 1024;
}
stream {
upstream web {
server 111.1.1.2:80; # 注:这里是真实服务器源IP
}
server {
listen 0.0.0.0:80;
proxy_timeout 20s;
proxy_pass web;
}
}
启动nginx
[root@locahost conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@locahost conf]# /usr/local/nginx/sbin/nginx -s reload
参考 https://nginx.org/en/docs/stream/ngx_stream_core_module.html