Skip to content

Instantly share code, notes, and snippets.

@costajob
Last active August 4, 2016 15:32
Show Gist options
  • Save costajob/403899ad34c92d5ffc65961f0729f6b5 to your computer and use it in GitHub Desktop.
Save costajob/403899ad34c92d5ffc65961f0729f6b5 to your computer and use it in GitHub Desktop.
Nginx and haproxy configuration for balancing a bunch of HTTP servers running on different ports
global
maxconn 4096
pidfile /tmp/haproxy-queue.pid
defaults
mode http
timeout connect 300000
timeout client 300000
timeout server 300000
maxconn 2000
frontend http-in
bind *:8080
default_backend servers
backend servers
balance roundrobin
server app1 127.0.0.1:9292 maxconn 100
server app2 127.0.0.1:9293 maxconn 100
server app3 127.0.0.1:9294 maxconn 100
server app4 127.0.0.1:9295 maxconn 100
server app5 127.0.0.1:9296 maxconn 100
server app6 127.0.0.1:9297 maxconn 100
server app7 127.0.0.1:9298 maxconn 100
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
gzip on;
keepalive_requests 1000;
proxy_http_version 1.1;
proxy_set_header Connection "";
upstream backend {
server 127.0.0.1:9292;
server 127.0.0.1:9293;
server 127.0.0.1:9294;
server 127.0.0.1:9295;
server 127.0.0.1:9296;
server 127.0.0.1:9297;
server 127.0.0.1:9298;
keepalive 100;
}
server {
listen 8080;
server_name localhost;
location / {
proxy_pass http://backend;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment