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
| class Module | |
| ROMAN_NUMERALS = { | |
| 'M'=> 1000, | |
| 'CM'=> 900, | |
| 'D'=> 500, | |
| 'CD'=> 400, | |
| 'C'=> 100, | |
| 'XC'=> 90, | |
| 'L'=> 50, | |
| 'XL'=> 40, |
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
| defaults | |
| mode http | |
| frontent fe | |
| bind :8080 | |
| use_backend be | |
| backend be | |
| # do whatever... |
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 foo | |
| bind :443 ssl crt /path/to/certs | |
| # Ensure we have a clean state to start with | |
| http-request del-header X-SERVER-SNI | |
| # Set the concatenated value of the SNI value to a temporary header | |
| http-request set-header X-SERVER-SNI haproxy.%[ssl_fc_sni] if { ssl_fc_sni -m found } | |
| # Set the value of the header to a transaction-level variable |
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
| # Build a new (internal) header containing the required full-base data | |
| # Unfortunately, we can't use variables here since they can't be used to concat data | |
| http-request set-header X-Full-Base %[base] | |
| http-request set-header X-Full-Base %[base]?%[query] if { query -m found } | |
| http-request deny if { req.hdr(X-Full-Base),map(/path/to/url_list.txt) -m found } | |
| # cleanup | |
| http-request del-header X-Full-Base |
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
| # First extract the rate into a variable called req.src_http_req_rate | |
| http-request content set-var req.src_http_req_rate %[src_http_req_rate] | |
| # Then use this variable in the acl by subtracting the current rate from the | |
| # value returned from the map. If the result is less than 0, the request rate | |
| # is larger than the allowed value | |
| acl abuse src,map_ip_int(/etc/haproxy/ips.map),sub(req.src_http_req_rate) -m int lt 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
| The MIT License (MIT) | |
| Copyright (c) 2015 Holger Just, Planio GmbH | |
| Permission is hereby granted, free of charge, to any person obtaining a copy | |
| of this software and associated documentation files (the "Software"), to deal | |
| in the Software without restriction, including without limitation the rights | |
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| copies of the Software, and to permit persons to whom the Software is | |
| furnished to do so, subject to the following conditions: |
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
| acl httponly_cookie res.hdr(Set-Cookie),lower -m sub httponly | |
| rspirep ^(set-cookie:.*) \1;\ HttpOnly if !httponly_cookie |
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
| listen tls | |
| bind *:443 | |
| mode tcp | |
| tcp-request inspect-delay 5s | |
| tcp-request content accept if { req_ssl_hello_type 1 } | |
| # deny clients not sending an SNI header in 5 seconds | |
| tcp-request content reject |
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
| regex_which_matches_4_byte_utf8_characters = /[\u{ffff}-\u{10FFFF}]/ |
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
| # In HAProxy 1.5, we have to jump through some hops to accomplish a rewrite of a request's path... | |
| # We use a temporary header to build our new path from the existing one in the request | |
| # and then directly perform a redirect | |
| # Clean the request and remove any existing header named X-Rewrite | |
| http-request del-header X-REWRITE | |
| # Copy the full request URL into the X-REWRITE request header unchanged | |
| http-request add-header X-REWRITE %[url] if { path_beg /foo } |