Skip to content

Instantly share code, notes, and snippets.

@samartioli
Created December 3, 2017 15:55
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 samartioli/f1792cfb65ce13c2400d369bbb7da9f3 to your computer and use it in GitHub Desktop.
Save samartioli/f1792cfb65ce13c2400d369bbb7da9f3 to your computer and use it in GitHub Desktop.
Simple configs for haproxy and ngingx load balancing
### HAPROXY EXAMPLE ###
global
maxconn 4096
defaults
log global
mode http
option httplog
option dontlognull
option forwardfor
option http-server-close
option redispatch
stats enable
stats auth user:password
stats uri /hap-stats
timeout connect 5000
timeout client 50000
timeout server 50000
frontend https
bind *:80
# bind *:443 ssl crt /path/to/cert/ssl.pem
default_backend my-service
backend my-service
balance roundrobin
server server-1 10.1.0.101:80 check
server server-2 10.1.0.102:80 check
server server-3 10.1.0.103:80 check
### NGINX EXAMPLE ###
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
# sendfile on;
keepalive_timeout 65;
upstream my-service {
server 10.1.0.101;
server 10.1.0.102;
server 10.1.0.103;
}
server {
listen 80;
# listen 443 ssl;
# server_name <domain name>;
# ssl_certificate /path/to/cert/cert.pem;
# ssl_certificate_key /path/to/key/privkey.pem;
location / {
proxy_pass http://my-service;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment