I am trying to redirect all API calls to an authorization service endpoint using nginx. I will need to pass a custom header in which i intend to pass the original uri or $request_uri. Trying the below:
location /api/other {`
add_header X-Original_URI $request_uri
return 308 https://example.com/myauthservice/api/authorize
}
unfortunately the header is not getting added, need some help to see if this is correct way to do.
I tried auth_request module, proxy_pass. auth_request I cannot use, as it cannot send $request_body. Followed this, but not able store or capture the $request_body.
proxy_pass I am not able to use as it ends up like this:
https://myauthservice/api/authorize/createuser
where createuser is from https://example.com/api/other/createuser
308 Permanent Redirectresponse after theLocationheader, but that won't made the browser send that header as part of the request tohttps://example.com/myauthservice/api/authorizeURI. I don't see any ways to do it but to proxy that request with theproxy_passdirective using something likelocation /api/other { rewrite ^ / break; proxy_set_header X-Original-URI $request_uri; proxy_pass https://example.com/myauthservice/api/authorize; }.https://example.com/myauthservice/api/authorizeis an argument forproxy_pass, isn't it?