-
-
Save haproxytechblog/0848e74f9db1abe9a02c40bfdf8ee742 to your computer and use it in GitHub Desktop.
Announcing HAProxy 3.4
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 | |
| stats socket /run/haproxy/admin.sock user haproxy group haproxy mode 660 level admin | |
| defaults mydefaults | |
| log global | |
| mode http | |
| option httplog | |
| option dontlognull | |
| timeout connect 10m | |
| timeout client 10m | |
| timeout server 10m | |
| frontend mysite | |
| bind :80 | |
| use_backend %[path,map_beg(virt@paths.map)] | |
| default_backend webservers | |
| backend webservers | |
| server web1 127.0.0.1:8080 |
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
| # Add a backend named 'test-backend' | |
| echo "add backend test-backend from mydefaults mode http" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # 'New backend registered.' | |
| # Add a server to the backend | |
| echo "add server test-backend/server1 127.0.0.1:3000 check" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # 'New server registered.' | |
| # Enable the server | |
| echo "enable server test-backend/server1" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # Enable health checks | |
| echo "enable health test-backend/server1" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # Publish the backend | |
| echo "publish backend test-backend" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # 'Backend published.' | |
| # Add an entry to the map file | |
| echo "add map virt@paths.map /test test-backend" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # Show map displays entry_cnt | |
| echo "show map" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # id (file) description | |
| 5 (virt@paths.map) pattern loaded from file 'virt@paths.map' used by map at file '/etc/haproxy/hapee-lb.cfg' line 45. curr_ver=0 next_ver=0 entry_cnt=1 |
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
| # Place the server into maintenance mode | |
| echo "set server test-backend/server1 state maint" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # Wait for the server to be removable | |
| # then remove the server | |
| echo "wait 2s srv-removable test-backend/server1; del server test-backend/server1" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # 'Server deleted.' | |
| # Unpublish the backend | |
| echo "unpublish backend test-backend" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # 'Backend unpublished.' | |
| # Wait for the backend to be removable | |
| # then delete the backend | |
| echo "wait 2s be-removable test-backend; del backend test-backend" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # 'Backend deleted.' | |
| # Delete the map file entry | |
| echo "del map virt@paths.map /test" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # Show map displays entry_cnt | |
| echo "show map" | sudo socat stdio unix-connect:/run/haproxy/admin.sock | |
| # id (file) description | |
| 5 (virt@paths.map) pattern loaded from file 'virt@paths.map' used by map at file '/etc/haproxy/hapee-lb.cfg' line 45. curr_ver=0 next_ver=0 entry_cnt=0 |
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
| frontend mysite | |
| bind :80 | |
| use_backend webservers | |
| # Enable QMux in the backend | |
| backend webservers | |
| server myserver 127.0.0.1:443 ssl verify none alpn h3,h2 | |
| # Enable QMux in the frontend | |
| frontend qmux-fe | |
| bind :443 ssl crt /etc/haproxy/ssl.pem alpn h3,h2 | |
| http-request return status 200 content-type text/plain string "Hello, qmux!" |
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
| backend web_servers | |
| filter comp-res | |
| compression algo gzip | |
| compression type text/css text/html text/javascript application/javascript text/plain text/xml application/json |
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
| log-profile syslog | |
| log-tag "haproxy" | |
| on close format "$HAPROXY_HTTP_LOG_FMT" | |
| on http-req format "%[var(req.log_message)]" | |
| frontend mysite | |
| bind :80 | |
| acl is_evil_client req.hdr(user-agent) -m sub evil | |
| http-request set-var(req.log_message) str("Blocking evil client") if is_evil_client | |
| http-request do-log profile syslog | |
| http-request deny if is_evil_client |
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 | |
| cpu-policy performance threads-per-core 1 | |
| cpu-affinity per-core |
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 | |
| cpu-affinity per-ccx | |
| max-threads-per-group 4 |
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
| healthcheck mycheck | |
| type httpchk | |
| http-check connect alpn h2 | |
| http-check send meth HEAD uri /health ver HTTP/2 hdr Host www.example.com | |
| backend webservers | |
| server web1 10.0.0.1:80 check healthcheck mycheck |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment