#请注意,stream块和http块是两个不同的模块,#stream不属于http模块,即不能放到/etc/nginx/conf.d/,#stream是通过tcp层转发,而不是http转发。#如配置在http内,启动nginx会报如下错误:
nginx: [emerg]"server" directive is not allowed here
修改主配置文件,添加stream目录
cd /etc/nginx/
cp-a nginx.conf{,_$(date +%F)}
vim nginx.conf
# 最后追加如下内容# tcp/ip proxy
include /etc/nginx/tcp.d/*.conf;