采用 yum install nginx后,会加载很多默认配置,可以通过 nginx -V 查看。但是进入模块下发现没有(ll /usr/lib64/nginx/modules/),可以采取 yum -y install nginx-all-modules.noarch 进行下载。
如采用stream模块对nginx http和https分流
load_module /usr/lib64/nginx/modules/ngx_stream_module.so;
events {
worker_connections 2048;
}
stream {
upstream http_gateway {
# 9200是一个开启http的端口
server 127.0.0.1:9200;
}
upstream https_gateway {
# 9201端口是一个开启https的端口
server 127.0.0.1:9201;
}
# 根据不同的协议走不同的upstream
map $ssl_preread_protocol $upstream{
default http_gateway;
"TLSv1.0" https_gateway;
"TLSv1.1" https_gateway;
"TLSv1.2" https_gateway;
"TLSv1.3" https_gateway;
}
server {
listen 9203;
ssl_preread on;
proxy_pass $upstream;
}
}