HAProxy-后端服务器的基本身份验证 [英] HAProxy - basic authentication for backend server

查看:91
本文介绍了HAProxy-后端服务器的基本身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下配置从本地127.0.0.1:2000代理访问Internet.

I use the following configuration to access internet from local 127.0.0.1:2000 proxy to the internet.:

global
    log 127.0.0.1   local0
    log 127.0.0.1   local1 notice
    #log loghost    local0 info
    maxconn 4096
    #chroot /usr/share/haproxy
    user haproxy
    group haproxy
    daemon
    #debug
    #quiet

defaults
    log global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    maxconn 2000
    contimeout  5000
    clitimeout  50000
    srvtimeout  50000

listen appname 0.0.0.0:2000
    mode http
    stats enable
    acl white_list src 127.0.0.1 
    tcp-request content accept if white_list
    tcp-request content reject
    stats uri /haproxy?stats
    stats realm Strictly\ Private
    stats auth special_admin:special_username
    balance roundrobin
    option httpclose
    option forwardfor
    server lamp1 23.123.1.110:3128 check

不幸的是,我需要通过http基本身份验证"special_admin:special_username"对我的外部代理23.123.1.110进行身份验证.我的问题是,有没有办法使用像

Unfortunately I need to authenticate to my external proxy 23.123.1.110 via http basic authentication "special_admin:special_username". My question is, is there any way to use basic authentication like :

server lamp1 http://special_admin:special_username@23.123.1.110:3128 check

谢谢

推荐答案

在您的示例中,您只需添加必要的 Authorization 标头以及授权方法和 username:password 编码为base64,如下所示:

In your example you only need to add the necessary Authorization header with the authorization method and the username:password encoded as base64 like this:

reqadd Authorization:\ Basic\ c3BlY2lhbF9hZG1pbjpzcGVjaWFsX3VzZXJuYW1l

我这样创建了base64编码的字符串:

I created the base64 encoded string like this:

echo -n "special_admin:special_username" | base64

有关HTTP基本授权的更多详细信息,请参见 https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side

For more details about HTTP Basic authorization see https://en.wikipedia.org/wiki/Basic_access_authentication#Client_side

这篇关于HAProxy-后端服务器的基本身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆