Nginx:是否有可能从auth_request重新调整响应 [英] Nginx: Is it possible to get response retuned from auth_request

查看:182
本文介绍了Nginx:是否有可能从auth_request重新调整响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为nginx使用auth模块. ( http://nginx.org/en/docs/http/ngx_http_auth_request_module.html) 是否可以通过某种方式存储来自/auth的响应,所以我可以将其作为请求正文发送到另一个端点.

I am using auth module for nginx. (http://nginx.org/en/docs/http/ngx_http_auth_request_module.html) Is it possible somehow to store the response from the /auth, so I can send it as a request body to another endpoint.

location /private/ {
    auth_request /auth;
    proxy_pass ... 
    proxy_set_body 'Here I want to put /auth response. How?';
}

location = /auth {
    proxy_pass ...
}

推荐答案

简短答案:

不,你不能.

长答案:

您无法将响应的正文返回给auth_request.不过,您可以使用 auth_request_set 指令获得响应中返回的标头:

You can't get body of a response returned to auth_request. You can get a header returned in the response though, using the auth_request_set directive:

location / {
    auth_request /auth;
    auth_request_set $auth_foo $upstream_http_foo;
    proxy_pass ...
    proxy_set_body $auth_foo;
}

上述配置会将$auth_foo变量设置为auth子请求的Foo标头的值.

The above configuration will set the $auth_foo variable to the value of Foo header of an auth subrequest.

这篇关于Nginx:是否有可能从auth_request重新调整响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆