Skip to content

Instantly share code, notes, and snippets.

View lifeblood's full-sized avatar

Daniel Shaw lifeblood

View GitHub Profile
@bavovna
bavovna / termination_state.txt
Created September 30, 2020 19:26
HAProxy termination_state
From https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#8.5
Session state at disconnection
TCP and HTTP logs provide a session termination indicator in the
"termination_state" field, just before the number of active connections. It is
2-characters long in TCP mode, and is extended to 4 characters in HTTP mode,
each of which has a special meaning :
- On the first character, a code reporting the first event which caused the
# Exit on Error
set -e
OUTPUT_DIR=/secrets
CA_FILE=$OUTPUT_DIR/elastic-stack-ca.p12
CERT_FILE=$OUTPUT_DIR/elastic-certificates.p12
printf "====== Generating Elasticsearch Certifications ======\n"
printf "=====================================================\n"
if [ -f "$CA_FILE" ]; then
@guycalledseven
guycalledseven / haproxy.md
Last active April 16, 2024 12:40
haproxy conditions

Haproxy conditions

Since I keep forgetting them I've put them here.

To form a condition, you can use the following syntax after the rule that it applies to:

<HAProxy action statement> if|unless [!]acl1 <AND|OR|or|'||'> [!]acl2 ...

  • if - the condition is TRUE if the result of the ACLs is TRUE.
@zakkak
zakkak / gist:ab08672ff9d137bbc0b2d0792a73b7d2
Created March 24, 2020 23:25
Resizing a filesystem using qemu-img and fdisk

Occasionally we will deploy a virtual instance into our KVM infrastructure and realize after the fact that we need more local disk space available. This is the process we use to expand the disk image. This process assumes the following:

  • You're using legacy disk partitions. The process for LVM is similar and I will describe that in another post.
  • The partition you need to resize is the last partition on the disk.

This process will work with either a qcow2 or raw disk image. For

@haproxytechblog
haproxytechblog / blog20181017-01.map
Last active August 21, 2023 15:42
Introduction to HAProxy Maps
# A comment begins with a hash sign
static.example.com be_static
www.example.com be_static
# You can add additional comments, but they must be on a new line
example.com be_static
api.example.com be_api
@haproxytechblog
haproxytechblog / blog20180913-01.cfg
Last active June 14, 2022 14:21
Introduction to HAProxy ACLs
acl is_static path -i -m beg /static/
@jasonrudolph
jasonrudolph / git-branches-by-commit-date.sh
Created February 12, 2012 20:40
List remote Git branches and the last commit date for each branch. Sort by most recent commit date.
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@perusio
perusio / gist:1326701
Created October 31, 2011 01:28
Mobile device detection in Nginx with just 7 lines of configuration
### Testing if the client is a mobile or a desktop.
### The selection is based on the usual UA strings for desktop browsers.
## Testing a user agent using a method that reverts the logic of the
## UA detection. Inspired by notnotmobile.appspot.com.
map $http_user_agent $is_desktop {
default 0;
~*linux.*android|windows\s+(?:ce|phone) 0; # exceptions to the rule
~*spider|crawl|slurp|bot 1; # bots
~*windows|linux|os\s+x\s*[\d\._]+|solaris|bsd 1; # OSes