


























通过在nginx中,设置auth_request 参数。可以实现身份验证。
events{}
http{
server {
listen 80; #监听端口;
server_name localhost; #服务器名称或域名;
location / {
auth_request /auth; #要跳转的路由路径;
proxy_pass http://localhost:52744/Auth;
}
#身份验证判断用户名和密码的方法的地址。此处例子登陆成功后跳转到/api/token/validate;
location /Auth/Login {
proxy_pass http://localhost:52744/Auth/Login;
# Login service returns a redirect to the original URI
# and sets the cookie for the ldap-auth daemon
proxy_set_header X-Target $request_uri;
}
#身份验证成功后的地址,可以后台的api。只要能判断是否验证成功就行;
location /api/token/validate {
proxy_pass http://localhost:52744/api/token/validate;
# Login service returns a redirect to the original URI
# and sets the cookie for the ldap-auth daemon
proxy_set_header X-Target $request_uri;
}
#执行身份验证的登陆页面地址,此处的页面会提交表单到/Auth/Login;
location /auth {
internal;
proxy_pass http://localhost:52744/Auth;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Target $request_uri;
}
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。