how to add basic authentication on haproxy backend server

258

how to add basic authentication on haproxy backend server -

# haproxy conf
global
  log 127.0.0.1   local1
  maxconn 4096

defaults
  mode http
  maxconn 2048

userlist AuthUsers
        user admin password $6$SydPP/et7BGN$C5VIhcn6OxuIaLPhCDCmzJyqDYQF8skik3J6sApkXPa6YPSVGutcgQPpdX/VEycGNi3sw7NxLSflEb53gzJtA1

frontend nginx-frontend
  bind *:5000
  mode http
  timeout connect 5s
  timeout client 5s
  timeout server 5s
  default_backend nginx-backend

  acl authusers_acl http_auth(AuthUsers)      
  http-request auth realm nginx-backend if !authusers_acl

backend nginx-backend
  server nginx nginx:80  check inter 5s rise 2 fall 3
  
#########

# Install this package to generate hash password
sudo apt-get install whois

# mkpasswd -m sha-512 <password>
mkpasswd -m sha-512 admin@456

# expected output
$6$gnGNapo/XeXYg39A$T/7TDfMrZXUDPbv5UPYemrdxdh5xEwqBrzSbpJYs9rfxLbQtgQzxyzkSGWIVOEGze8KrsA0urh3/dG.1xOx3M0

# Copy the generated password and paste in haproxy.cfg file

#Deploy the containers to test configuration

sudo docker run -d --name nginx nginx
sudo docker run -d -p 5000:5000 --name haproxy --link nginx:nginx -v /home/users/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg haproxy

# Check in the browser, username and password will be prompted.

Comments

Submit
0 Comments

More Questions

cmd cant change directoryhow to open d drive using conda prompt how to add basic authentication on haproxy backend server
cmd cd not workingvideo player html express hello world
form submit with file upload in phpcreate latex document button avalonia
simple deployment diagram for basic crud operationsc# sockets guzzlehttp authorization basic
using axios get with authorizationpehkui mod forge c# restclient get basic authentication
curl authJASON WEB TOKENS EM VBNET COM WINDOWS FORMS git commands
c64 basic define variableauthentication in fetch post how to create authentication and authorization in local api angular 14
basic array questionsc++ code snippets what are the 3 basic types of plate boundaries explain their differences (how they act).
pandas column statisticshow to make a calculator in python pygame window
raylib c# basic windowsmall basic textwindow npm err! code e401 npm err! unable to authenticate, need: basic realm=https:--pkgsprodeus21.pkgs.visualstudio.com-
split a column in google sheetshow to serve html file in node.js vba check if range is empty
create route in laravel 8golang http post authentication lib in tsconfig
range recursion javascriptvbs error message how to make an exit button using vs code
how to delete a value from document in mongodbvb.net remove case sensitivity face recognition python opencv haar cascade
curl to upload to artifactoryunity simple movement script node-fetch auth
basic symbol meanings in c++visual basic variable declaration visual basic run command