2015-11-23 45 views
1

我用下面的配置从本地127.0.0.1:2000代理访问互联网,以互联网:HAProxy的 - 对后端服务器

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 

不幸的是我需要验证我的外部代理23.123.1.110基本身份验证通过http基本认证“special_admin:special_username”。 我的问题是,有没有办法使用基本身份验证,如:

server lamp1 http://special_admin:[email protected]:3128 check 

感谢

回答

2

在您的例子中,你只需要与授权方法添加必要的Authorization头和username:password编码为喜欢的base64这样的:

reqadd Authorization:\ Basic\ c3BlY2lhbF9hZG1pbjpzcGVjaWFsX3VzZXJuYW1l 

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

echo -n "special_admin:special_username" | base64 

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

+0

THX我要考...... – ovntatar

+0

与代理授权值工作。 http://stackoverflow.com/questions/386431/authenticated-proxies-on-haproxy-load-balancer – ovntatar

+0

嗯,你说得对,那样头只能用于一跳。感谢您的链接! – gesellix