Search
 
SCRIPT & CODE EXAMPLE
 

BASIC

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.
Comment

PREVIOUS NEXT
Code Example
Basic :: cmd cd not working 
Basic :: tmux basic commands 
Basic :: freecodecamp basic algorithm scripting return largest numbers in arrays 
Basic :: Console.OutputEncoding c# 
Basic :: Trollbox 
Basic :: using amazon s3 to store your django sites static and media files 
Basic :: how to dynamically change the font size of a button visual basic 
Elixir :: elixir string to date 
Elixir :: HTTPoison post json 
Elixir :: elixir module 
Elixir :: how to split a string in elixir 
Elixir :: elixir pipeline 
Scala :: scala read lines from file 
Scala :: is there scala lint 
Scala :: scala list of options to option of list 
Actionscript :: mount_osxfuse: /Users/em/mount_dev: Input/output error 
Excel :: excel auto fit row height 
Perl :: perl foreach loop 
Perl :: Perl (perl 5.28.1) sample 
Pascal :: pascal error handling 
Powershell :: takeown command 
Gdscript :: godot 
Lisp :: common lisp ide macos 
Assembly :: does assembly language use registers 
Assembly :: IPL_DEPTH_LABEL 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: filesaver.min.js cdn 
Javascript :: ajax cdn 
Javascript :: How to get the browser to navigate to a URL in JavaScript 
Javascript :: how to find number in string js 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =