antony@notes:~/rancher$ cat "nginx.conf-with-Rancher.LB.md"
nginx.conf with `Rancher.LB`
nginx.conf with Rancher.LB
user nginx;
worker_processes auto;
load_module /usr/lib64/nginx/modules/ngx_stream_module.so;
error_log /var/log/nginx/error.log;
error_log /var/log/nginx/error.log notice;
error_log /var/log/nginx/error.log info;
events {
worker_connections 1024;
use epoll;
}
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr"';
error_log /var/log/nginx/k8s-masters-lb-error.log;
access_log /var/log/nginx/k8s-masters-lb-access.log proxy;
# upstream k8s-masters {
# #hash $remote_addr consistent;
# server master01.example.com:6443 weight=1 max_fails=1;
# #server master02.example.com:6443 weight=1 max_fails=1;
# #server master03.example.com:6443 weight=1 max_fails=1;
# }
upstream rancher_http {
#hash $remote_addr consistent;
server rancher01.example.com:80 weight=1 max_fails=1;
server rancher02.example.com:80 weight=1 max_fails=1;
server rancher03.example.com:80 weight=1 max_fails=1;
}
upstream rancher_https {
#hash $remote_addr consistent;
server rancher01.example.com:443 weight=1 max_fails=1;
server rancher02.example.com:443 weight=1 max_fails=1;
server rancher03.example.com:443 weight=1 max_fails=1;
}
upstream rancher_certs {
#hash $remote_addr consistent;
server rancher01.example.com:2379 weight=1 max_fails=1;
server rancher02.example.com:2379 weight=1 max_fails=1;
server rancher03.example.com:2379 weight=1 max_fails=1;
}
upstream rancher_kubernetes_masters {
#hash $remote_addr consistent;
server rancher01.example.com:6443 weight=1 max_fails=1;
server rancher02.example.com:6443 weight=1 max_fails=1;
server rancher03.example.com:6443 weight=1 max_fails=1;
}
upstream rancher_nodeport_1_workers {
#hash $remote_addr consistent;
server worker01.example.com:31999 weight=1 max_fails=1;
# server agent02.example.com:31999 weight=1 max_fails=1;
# server agent03.example.com:31999 weight=1 max_fails=1;
}
# server {
# listen 31999;
#proxy_connect_timeout 1s;
#proxy_timeout 3s;
# proxy_pass rancher_nodeport_1_workers;
# }
server {
listen 6443;
#proxy_connect_timeout 1s;
#proxy_timeout 3s;
proxy_pass rancher_kubernetes_masters;
}
server {
listen 80;
proxy_pass rancher_http;
}
server {
listen 2379;
proxy_pass rancher_certs;
}
server {
listen 443;
proxy_pass rancher_https;
}
upstream rancher_wordpress_http_workers {
#hash $remote_addr consistent;
server worker01.example.com:30292 weight=1 max_fails=1;
#server worker02.example.com:30292 weight=1 max_fails=1;
#server worker03.example.com:30292 weight=1 max_fails=1;
}
server {
listen 30292;
proxy_pass rancher_wordpress_http_workers;
}
}Nginx Unit File
cat /usr/lib/systemd/system/nginx.service[Unit]
Description=The nginx HTTP and reverse proxy server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx -g "daemon off;"
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=mixed
PrivateTmp=true
[Install]
WantedBy=multi-user.target