在nginx中将自定义固定头传递给auth_请求
我需要一些指导,以便在nginx中将静态头传递给auth_请求。在nginx中将自定义固定头传递给auth_请求,nginx,auth-request,Nginx,Auth Request,我需要一些指导,以便在nginx中将静态头传递给auth_请求。 我的位置配置如下: location = /auth { internal; proxy_pass http://authserver.com:8009/auth; proxy_pass_request_body off; proxy_set_header Content-Length ""; proxy_set_header X-Original-URI $request_uri
我的位置配置如下:
location = /auth {
internal;
proxy_pass http://authserver.com:8009/auth;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
location = /app/finance/ {
proxy_pass_request_headers on;
# Custom header to be added
proxy_set_header CallType "MAJOR";
auth_request /auth;
error_page 401 =401 /auth;
proxy_pass http://myaddservice.com:8080/finance/;
}
我的子请求如下所示:location = /auth {
internal;
proxy_pass http://authserver.com:8009/auth;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_set_header X-Original-URI $request_uri;
}
location = /app/finance/ {
proxy_pass_request_headers on;
# Custom header to be added
proxy_set_header CallType "MAJOR";
auth_request /auth;
error_page 401 =401 /auth;
proxy_pass http://myaddservice.com:8080/finance/;
}
我需要将CallType标头传递给auth_请求。我已尝试使用add_标头、proxy_set_标头,但无效。我在auth_请求后面有一个Rest Api进行身份验证,该请求需要CallType头。
我无法使其作为api标头的一部分通过,因为它是一个内部进程。您可以尝试以下方法:
location=/auth{
内部的;
代理通行证http://authserver.com:8009/auth;
代理通过请求关闭;
代理集标题内容长度“”;
代理集头X-Original-URI$request\u URI;
代理集头调用类型$CallType;
}
地点=/app/finance/{
设置$calltype为“主要”;
代理\u传递\u请求\u头打开;
授权请求/授权;
错误\u第401页=401/auth;
代理通行证http://myaddservice.com:8080/finance/;
}
如果将从其他位置调用身份验证请求,则
$calltype
变量将具有空值,并且根本不会设置calltype
标头(如果将空值作为参数传递给add\u header
或proxy\u set\u header
指令,则nginx不会设置标头)这是CallType
头应该同时传递给myaddservice.com:8080
和authserver.com:8009
吗?不。我只需要在authserver.com中使用它。即使同时传递给两者,它也不会有任何影响。我也可以……有什么帮助吗