Created
January 22, 2012 10:21
-
-
Save bwiggs/1656490 to your computer and use it in GitHub Desktop.
HAProxy Config File Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
#debug # uncomment to enable debug mode for HAProxy | |
defaults | |
mode http # enable http mode which gives of layer 7 filtering | |
timeout connect 5000ms # max time to wait for a connection attempt to a server to succeed | |
timeout client 50000ms # max inactivity time on the client side | |
timeout server 50000ms # max inactivity time on the server side | |
backend legacy # define a group of backend servers to handle legacy requests | |
server legacy_server 127.0.0.1:8001 # add a server to this backend | |
frontend app *:80 # define what port to listed to for HAProxy | |
default_backend legacy # set the default server for all request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
#debug | |
defaults | |
mode http | |
option httpclose # close the tcp connection after every request | |
timeout connect 5000ms | |
timeout client 50000ms | |
timeout server 50000ms | |
backend legacy | |
server legacy_server 127.0.0.1:8001 | |
backend rails # define a group of backend servers to handle rails requests | |
server rails_server 127.0.0.1:8002 # add a server to this backend | |
frontend app *:80 | |
default_backend legacy | |
acl rails_path path_beg /profile # acl rule for paths to be handled by the new rails app | |
use_backend rails if rails_path # use rails if the rules match. |
Example from HAProxy documentation here
# Simple configuration for an HTTP proxy listening on port 80 on all
# interfaces and forwarding requests to a single backend "servers" with a
# single server "server1" listening on 127.0.0.1:8000
global
daemon
maxconn 256
defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:80
default_backend servers
backend servers
server server1 127.0.0.1:8000 maxconn 32
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is very helpful but I get
please use the 'bind' keyword for listening addresses
. Maybe newer versions require a slightly different syntax.