0

I want to know one thing that is it possible for the NGINX to return the response of one upstream server to another upstream.

I need this as when a request is received I want to get it validated from one upstream server, and if validated then only let the NGINX forward that request to the second upstream server which hosts the main processing engine. And once processed by the second server, it replies back with HTTP response.

learner
  • 906
  • 2
  • 10
  • 39
  • 1
    Take a look at http://nginx.org/en/docs/http/ngx_http_auth_request_module.html – Alexander Altshuler Feb 24 '17 at 11:29
  • Thanks Alexander. I have one unsolved mystry about nginx. After authenticating the request from auth server the request is forwarded by the NGINX to the upstream server. In this forwarding how does upstream server knows that the request is authenticaed? is there any http header that NGINX sets inside the request after authentication ? And this header is read by the upstream application to decide if the request is an authenticated request. And once authenticated how the authorization details are sent to upstream server ? does upstream server have to request these detail to auth server again. – learner Feb 26 '17 at 13:50
  • 1
    ngx_http_auth_request_module doesn't add any header. But if you really need it you may do it yourself - http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header – Alexander Altshuler Feb 27 '17 at 08:50
  • Then how would my upstream server know that the request reaching it is an authenticated request. Should upstream server just trust the request coming to it openly? And once authenticated the user gets the page and now clicks on to go to next page in application, will this request be sent to authenticate server again? Or nginx will see that the request is already authenticated previously and no need to send again to authenticate server till the session I'd expires – learner Feb 27 '17 at 09:34
  • Modules give you a tools. You may implement any logic you want. You may setup a cookie, for example, and check for this cookie in your auth. upstream server. – Alexander Altshuler Feb 27 '17 at 11:11
  • This means that if my auth module sets a cookie or an authorization header like jwt then my upstream server will also receive that and after processing send the cookie or authorization header back to client. And then the client has to send it back for future requests – learner Feb 28 '17 at 14:39

0 Answers0