Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create a Dockerfile
- FROM haproxy:1.7
- COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
- # Build the container
- docker build -t my-haproxy .
- # Test the configuration file
- docker run -it --rm --name haproxy-syntax-check my-haproxy haproxy -c -f /usr/local/etc/haproxy/haproxy.cfg
- # Run the container
- docker run -d --name my-running-haproxy my-haproxy
- # Contoh simple haproxy config, single port
- #---------------------------------------------------------------------
- # common defaults that all the 'listen' and 'backend' sections will
- # use if not designated in their block
- #---------------------------------------------------------------------
- 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 gpptraining 10.xxx.xxx.xx:30017 check
- #---------------------------------------------------------------------
- #HAProxy Monitoring Config
- #---------------------------------------------------------------------
- listen stats
- bind *:8404
- mode http
- log global
- maxconn 10
- stats enable
- stats hide-version
- stats show-node
- stats auth username:pwd
- stats uri /monit
- stats refresh 30s
- #stats admin if LOCALHOST
- # contoh multi port
- #---------------------------------------------------------------------
- # common defaults that all the 'listen' and 'backend' sections will
- # use if not designated in their block
- #---------------------------------------------------------------------
- global
- daemon
- maxconn 256
- defaults
- mode http
- timeout connect 5000ms
- timeout client 50000ms
- timeout server 50000ms
- frontend http-in
- bind *:80
- bind *:81
- acl p1 dst_port 80
- acl p2 dst_port 81
- use_backend servers1 if p1
- use_backend servers2 if p2
- backend servers1
- balance roundrobin
- server gpptraining 10.xxx.xxx.xxx:30017 check
- backend servers2
- balance roundrobin
- server gpptraining 10.xxx.xxx.xxx:30018 check
- #---------------------------------------------------------------------
- #HAProxy Monitoring Config
- #---------------------------------------------------------------------
- listen stats
- bind *:8404
- mode http
- log global
- maxconn 10
- stats enable
- stats hide-version
- stats show-node
- stats auth username:pwd
- stats uri /monit
- stats refresh 30s
- #stats admin if LOCALHOST
Add Comment
Please, Sign In to add comment