普通TCP
stream {
server {
listen 16380; #要監聽的端口
proxy_pass 192.168.0.195:6379; #要轉發的地址
}
}
SSL驗證的TCP
stream {
server {
listen 16380 ssl; #要監聽的端口
proxy_pass 192.168.0.195:6379; #要轉發的地址
ssl_certificate /data/crt/server.crt;
ssl_certificate_key /data/crt/server_no_passwd.key;
}
}
修改保存後, 執行 nginx -s reload 即可
可能遇到的問題:
提示該問題是因爲缺少 --with-stream_ssl_module 模塊
啥也不說了, 進入nginx根目錄, 直接安裝常用模塊
./configure --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-http_v2_module --with-stream --with-stream_ssl_module
make && make install