如何添加使用用户列表时没有要求输入密码的haproxy ip地址?
class Factory;
class Interface
{
protected:
Interface(){/*Do something*/};
public:
virtual ~Interface(){/*Do something*/}
/*I wish I could do below and it is valid for all inherited
classes but friendship is not inherited in C++*/
//friend Interface* Factory::create(Type)
};
class InheritedA:public Interface
{
private:
InheritedA(){/*Do something*/};
public:
virtual ~InheritedA(){/*Do something*/}
/*I dont want to do below two lines for every inherited class*/
//friend Interface Factory::create(Type)
//public: Interface* factoryInheritedA(){return new InheritedA();}
};
class InheritedB:public Interface
{
private:
InheritedB(){/*Do something*/};
public:
virtual ~InheritedA(){/*Do something*/}
};
class Factory
{
static Interface* create(Interface type)
{
switch(type)
{
case A:
return new InheritedA();
case B:
return new InheritedB();
default:
//exceptions etc
}
}
}
int main()
{
Interface* I = Factory::create(A/*or B*/);
return 0;
}
类似于apache中的auth basic
userlist user
user user insecure-password password
allow ip 1.1.1.1 [example]
答案 0 :(得分:0)
您需要使用haproxy ACL:
frontend example-frontend
acl ip_whitelist src 1.1.1.1
acl auth_ok http_auth(user)
# require authentication when not in whitelist and not authenticated
http-request auth if !ip_whitelist !auth_ok