Skip to content

Instantly share code, notes, and snippets.

@stfsy
Created January 16, 2017 21:49
Show Gist options
  • Save stfsy/6bd8d7f873d90d3e60689ee551f4fb0a to your computer and use it in GitHub Desktop.
Save stfsy/6bd8d7f873d90d3e60689ee551f4fb0a to your computer and use it in GitHub Desktop.
HAProxy Dockerfile with simple configuration

A HAProxy Dockerfile with a simple configuration

FROM haproxy:alpine
ADD proxy.cfg /usr/local/etc/haproxy/haproxy.cfg
EXPOSE 20308
EXPOSE 20301
#Put this in the file
global
# max processes processes
nbproc 1
# max connections
maxconn 5
defaults
mode http
# max time waiting for clients request
timeout http-request 500ms
# max time waiting for next request
timeout http-keep-alive 500ms
# max time waiting for server to establish connection
timeout connect 5000ms
# client side inactivity
timeout client 1000ms
# waiting for response
timeout server 50000ms
frontend http-in
bind 0.0.0.0:20308
use_backend backend1
backend backend1
option httpclose
option forwardfor
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
# ip adress of vb network config on windows 10
server server 192.168.56.1:8123 maxconn 5
listen admin
bind 0.0.0.0:20301
stats uri /stats
stats enable
docker run -p 20308:20308 -p 20301:20301 <<image name>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment