Skip to content

Instantly share code, notes, and snippets.

@aussielunix
Created June 5, 2022 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aussielunix/3a571ffd4e46536b8046b964434408a9 to your computer and use it in GitHub Desktop.
Save aussielunix/3a571ffd4e46536b8046b964434408a9 to your computer and use it in GitHub Desktop.
k3s nginx load balancer
user www-data;
pid /run/nginx.pid;
worker_processes auto;
worker_rlimit_nofile 40000;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 8192;
}
stream {
upstream http_servers {
least_conn;
server <NODE_IP>:80 max_fails=3 fail_timeout=5s;
server <NODE_IP>:80 max_fails=3 fail_timeout=5s;
server <NODE_IP>:80 max_fails=3 fail_timeout=5s;
server <NODE_IP>:80 max_fails=3 fail_timeout=5s;
}
upstream https_servers {
least_conn;
server <NODE_IP>:443 max_fails=3 fail_timeout=5s;
server <NODE_IP>:443 max_fails=3 fail_timeout=5s;
server <NODE_IP>:443 max_fails=3 fail_timeout=5s;
server <NODE_IP>:443 max_fails=3 fail_timeout=5s;
}
upstream k3s_servers {
server <CONTROL_NODE_IP>:6443;
server <CONTROL_NODE_IP>:6443;
}
server {
listen 80;
proxy_pass http_servers;
}
server {
listen 443;
proxy_pass https_servers;
}
server {
listen 6443;
proxy_pass k3s_servers;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment