Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
Last active November 5, 2020 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haproxytechblog/22928ddc024b036ea8ab33865f8a2ee6 to your computer and use it in GitHub Desktop.
Save haproxytechblog/22928ddc024b036ea8ab33865f8a2ee6 to your computer and use it in GitHub Desktop.
Announcing HAProxy 2.3
log-forward syslog-lb
bind :::7514 # Listen on TCP IPv4/IPv6
dgram-bind :::7514 # Listen on UDP IPv4/IPv6
# load balance messages on 4 udp syslog servers
log 10.1.0.2:10001 format rfc5424 sample 1:4 local0 info
log 10.1.0.3:10002 format rfc5424 sample 2:4 local0 info
log 10.1.0.4:10003 format rfc5424 sample 3:4 local0 info
log 10.1.0.5:10004 format rfc5424 sample 4:4 local0 info
$ echo "show stat domain dns" |socat tcp-connect:127.0.0.1:9999 -
# id, send_error, valid, update, cname, cname_error, any_err, nx, timeout, refused, other, invalid, too_big, truncated, outdated,
nameserver1, 0, 20, 0, 0, 10, 10, 0, 0, 0, 0, 0, 0, 0, 0,
frontend stats
bind :8404
stats enable
stats uri /
stats refresh 10s
stats show-modules
no log
# The old replace-path directive only replaces the path
# Add /foo to the end of the path
# /a/b/c?x=y --> /a/b/c/foo?x=y
http-request replace-path ([^?]+)(\?{1}[^?]+)? \1/foo
# Strip off the query string
# /a/b/c?x=y --> /a/b/c/foo
http-request replace-pathq ([^?]+)(\?{1}[^?]+)? \1/foo
# Add x=y to the query string
# /a/b/c?x=y --> /a/b/c/foo?x=y&foo=bar
http-request replace-pathq ([^?]+)(\?{1}[^?]+)? \1/foo\2&foo=bar
# The old set-path directive
# Prepend /foo to the path
# /a/b/c?x=y --> /foo/a/b/c?x=y
http-request set-path /foo%[path]
# The new set-pathq directive
# Strip off the query string
# /a/b/c?x=y --> /foo/a/b/c
http-request set-pathq /foo%[path]
http-request set-header x-forwarded-proto %[ssl_fc,iif(https,http)]
http-after-response set-header x-cache %[res.cache_hit,iif(Hit,Miss)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment