adamant-kite-43734
11/23/2023, 4:40 AMwide-author-88664
11/27/2023, 2:01 PMwide-author-88664
11/27/2023, 2:05 PMworker_processes 4;
worker_rlimit_nofile 40000;
events {
worker_connections 8192;
}
http {
upstream backend {
# Use the 'least_conn' load balancing method
least_conn;
# Specify the servers and their weights
server 192.168.1.100 max_fails=3 fail_timeout=5s;
server 192.168.1.101 max_fails=3 fail_timeout=5s;
}
# Define the server block for HTTP requests
server {
# Listen on port 80 for HTTP
listen 80;
# Redirect all HTTP requests to HTTPS
return 301 https://$host$request_uri;
}
# Define the server block for HTTPS requests
server {
# Listen on port 443 for HTTPS
listen 443 ssl;
# Specify the SSL certificate and key files
ssl_certificate /etc/ssl/certs/rancher.pem;
ssl_certificate_key /etc/ssl/private/rancher_private.key;
# Proxy the requests to the upstream group
location / {
proxy_pass <https://backend>;
}
}
}
wide-author-88664
11/27/2023, 2:09 PMdocker run -d --restart=unless-stopped -p 80:80 -p 443:443 -v /etc/nginx.conf:/etc/nginx/nginx.conf -v /etc/ssl:/etc/ssl --name nginx_lb nginx:stable