我有一个授权模块,每当向私有端点发出请求时都会调用该模块。
该模块从Authorization
标头中解析令牌,并且:
Authorization
标头中返回该令牌。“profile”是私有端点之一,它的配置方式如下:
location /profile {
auth_request /jwtverify;
auth_request_set $authorization $upstream_http_authorization;
proxy_set_header authorization $authorization;
proxy_pass http://private-profile:80;
}
Run Code Online (Sandbox Code Playgroud)
jwtverify
是这样配置的:
location = /jwtverify {
internal;
proxy_pass http://auth-module:8080/auth/verify;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
auth_request_set $http_authorization $upstream_http_authorization;
}
Run Code Online (Sandbox Code Playgroud)
现在,除了要求号外,一切正常。3:如果auth模块设置了Authorization
header,客户端永远不会收到它。
流程应该是这样的:
auth-module
拦截请求,如果有效,代理将其传递给私有服务auth-module
应保留由 设置的标头并发送给客户端我想我没有正确理解如何组合auth_request_set
, proxy_set_header
, auth_request_set
,也可能是它们不适合这种情况。
有没有办法在 NGINX 中实现这一点?
nginx ×1