authentication – nginx auth_request:访问原始查询参数

我想弄清楚是否可以将查询参数从原始URL转发到auth_request处理程序/服务?

用户应该能够将API标记添加为查询参数,如下所示:
https://example.com/api/user?token=237263864823674238476

而不是通过标题或cookie.我可以在auth-service中以某种方式访问令牌参数吗?或者使用NGINX在自定义标头中写入令牌查询参数?
到目前为止试过这个:

location = /api/user {
  auth_request /auth;
  proxy_set_header X-auth-token-from-query $arg_token;

  proxy_pass http://

/ auth端点没有获得X-auth-token-from-query标头但在返回200之后,上游代理确实获得了标头.
最佳答案
您很可能也希望将url(uri)传递给auth-request端点.你可以一次性做到这一点:

location = /api/auth {
  proxy_set_header X-Original-URI $request_uri;
  proxy_set_header X-Original-METHOD $request_method;
  proxy_pass_request_body off;
  proxy_set_header Content-Length "";

  proxy_pass http://

额外奖励:我也通过了这个方法! :田田:

dawei

【声明】:唐山站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。