Skip to content

Instantly share code, notes, and snippets.

@ba0f3
Forked from Iristyle/gist:5005653
Created December 3, 2018 04:13
Show Gist options
  • Save ba0f3/3d3e33080c0c82d6fc1717441ca411ab to your computer and use it in GitHub Desktop.
Save ba0f3/3d3e33080c0c82d6fc1717441ca411ab 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