Skip to content

Instantly share code, notes, and snippets.

@satblip
Forked from Iristyle/gist:5005653
Created September 13, 2018 10:46
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 satblip/e743a1f0d43399936deedd084e8946f3 to your computer and use it in GitHub Desktop.
Save satblip/e743a1f0d43399936deedd084e8946f3 to your computer and use it in GitHub Desktop.
Configure HAProxy for userlists

Create SHA512 passwords

# make sure to use a leading space so that the command is not stored in your bash history!!
 mkpasswd -m sha-512 password1
# generates -> $6$yMgsow58.g/Z$mBjHfdVzqcF/LN.iwV23Eyqg.yGPTsp9pOwaStsJ6c4I4zL7BhucVVAkv5guf7OVRr8Pw0mHF4NrWBRCG5ci7/
 mkpasswd -m sha-512 password2
# generates -> $6$RZ86vRkQ$aRKN1HOsk6bDHBbMhS7jSo/p1NGFl4PvwY3KpU.72i./LvITi41nL84EkxOFXl.6Bmhynj/L7pYbfF0rUHtOB0

Edit /etc/haproxy/haproxy.cfg

userlist UsersFor_Ops
  group AdminGroup users userone,usertwo
  user userone password $6$yMgsow58.g/Z$mBjHfdVzqcF/LN.iwV23Eyqg.yGPTsp9pOwaStsJ6c4I4zL7BhucVVAkv5guf7OVRr8Pw0mHF4NrWBRCG5ci7/
  user usertwo password $6$RZ86vRkQ$aRKN1HOsk6bDHBbMhS7jSo/p1NGFl4PvwY3KpU.72i./LvITi41nL84EkxOFXl.6Bmhynj/L7pYbfF0rUHtOB0


...


backend myserver
    mode    http
    server  myserver   1.1.1.1:80
    acl AuthOkay_Ops http_auth(UsersFor_Ops)
    http-request auth realm MyAuthRealm if !AuthOkay_Ops
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment