Skip to content

Instantly share code, notes, and snippets.

@bprashanth
Created October 23, 2015 17:33
Show Gist options
  • Save bprashanth/790260fdc44ada7efdac to your computer and use it in GitHub Desktop.
Save bprashanth/790260fdc44ada7efdac to your computer and use it in GitHub Desktop.
# This file uses golang text templates (http://golang.org/pkg/text/template/) to
# dynamically configure the haproxy loadbalancer.
global
daemon
stats socket /tmp/haproxy
defaults
log global
# Enable session redistribution in case of connection failure.
option redispatch
# Disable logging of null connections (haproxy connections like checks).
# This avoids excessive logs from haproxy internals.
option dontlognull
# Enable HTTP connection closing on the server side.
option http-server-close
# Enable insertion of the X-Forwarded-For header to requests sent to
# servers and keep client IP address.
option forwardfor
# Enable HTTP keep-alive from client to server.
option http-keep-alive
# Clients should send their full http request in 5s.
timeout http-request 5s
# Maximum time to wait for a connection attempt to a server to succeed.
timeout connect 5s
# Maximum inactivity time on the client side.
# Applies when the client is expected to acknowledge or send data.
timeout client 50s
# Inactivity timeout on the client side for half-closed connections.
# Applies when the client is expected to acknowledge or send data
# while one direction is already shut down.
timeout client-fin 50s
# Maximum inactivity time on the server side.
timeout server 50s
# timeout to use with WebSocket and CONNECT
timeout tunnel 1h
# Maximum allowed time to wait for a new HTTP request to appear.
timeout http-keep-alive 60s
# default traffic mode is http
# mode is overwritten in case of tcp services
mode http
# default default_backend. This allows custom default_backend in frontends
default_backend default-backend
backend default-backend
server localhost 127.0.0.1:8081
frontend httpfrontend
# Frontend bound on all network interfaces on port 80
bind *:80
acl url_acl_mypage path_beg /foobar
use_backend mypage if url_acl_mypage
backend mypage
option httplog
balance roundrobin
reqrep ^([^\ :]*)\ /foobar[/]?(.*) \1\ /\2
server localhost:8000 localhost:8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment