// 安装 nginx
$ yum -y install nginx
// 代理 rancher 四层协议
$ vim /etc/nginx/nginx.conf
worker_processes 4;
worker_rlimit_nofile 40000;
events {
worker_connections 8192;
}
stream {
upstream rancher_servers_http {
least_conn;
server 192.168.10.201:80 max_fails=3 fail_timeout=5s;
server 192.168.10.202:80 max_fails=3 fail_timeout=5s;
}
server {
listen 80;
proxy_pass rancher_servers_http;
}
upstream rancher_servers_https {
least_conn;
server 192.168.10.201:443 max_fails=3 fail_timeout=5s;
server 192.168.10.202:443 max_fails=3 fail_timeout=5s;
}
server {
listen 443;
proxy_pass rancher_servers_https;
}
}
//启动 nginx 报错
$ systemctl start nginx
$ systemctl status nginx
...
Jan 31 15:52:06 c710239.xiodi.cn nginx[20266]: nginx: [emerg] unknown directive "stream" in /etc/nginx/nginx.conf:8
Jan 31 15:52:06 c710239.xiodi.cn nginx[20266]: nginx: configuration file /etc/nginx/nginx.conf test failed
...
// 缺少模块
$ yum -y install nginx-mod-stream
$ vim /etc/nginx/nginx.conf // 载入模块
load_module /usr/lib64/nginx/modules/ngx_stream_module.so;
worker_processes 4;
worker_rlimit_nofile 40000;
...
$ systemctl start nginx
作者:jackzang 创建时间:2023-01-31 16:13
最后编辑:jackzang 更新时间:2024-06-28 13:36
最后编辑:jackzang 更新时间:2024-06-28 13:36