Quantcast

Is it possible to analyze result and query a second server?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Is it possible to analyze result and query a second server?

Jason Bronnx

Hi,

Tried to search on this for a couple of hours, but had no luck, hoping you guys can help.

I have a use case, that I need to proxy the request to server-A first, then if returns 200, then it'll query server-B and return that result.  If it returned != 200, just return 404.  Something like this:

function pseudoCode() {
  if (server-a.process() == 200) {
    return server-b.process()
  }

  // Got a non-200 from server-a, just return 404
  return 404
}

Is there a straightforward way of doing this in nginx?

Thanks!
Jason

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it possible to analyze result and query a second server?

Aleksandar Lazic
Hi Jason.

Am Wed, 10 May 2017 21:02:36 -0700
schrieb Jason Bronnx <[hidden email]>:

> Hi,
>
> Tried to search on this for a couple of hours, but had no luck,
> hoping you guys can help.
>
> I have a use case, that I need to proxy the request to server-A
> first, then if returns 200, then it'll query server-B and return that
> result.  If it returned != 200, just return 404.  Something like this:
>
> function pseudoCode() {
>   if (server-a.process() == 200) {
>     return server-b.process()
>   }
>
>   // Got a non-200 from server-a, just return 404
>   return 404
> }
>
> Is there a straightforward way of doing this in nginx?

I assume you will be able to do this with perl/lua.

http://nginx.org/en/docs/http/ngx_http_perl_module.html
https://github.com/openresty/lua-nginx-module#readme

> Thanks!
> Jason

Regards
Aleks
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is it possible to analyze result and query a second server?

Roman Arutyunyan
In reply to this post by Jason Bronnx
Hi Jason,

On Wed, May 10, 2017 at 09:02:36PM -0700, Jason Bronnx wrote:

> Hi,
>
> Tried to search on this for a couple of hours, but had no luck, hoping you
> guys can help.
>
> I have a use case, that I need to proxy the request to server-A first, then
> if returns 200, then it'll query server-B and return that result.  If it
> returned != 200, just return 404.  Something like this:
>
> function pseudoCode() {
>   if (server-a.process() == 200) {
>     return server-b.process()
>   }
>
>   // Got a non-200 from server-a, just return 404
>   return 404
> }
>
> Is there a straightforward way of doing this in nginx?

Take a look at ngx_http_auth_request_module:

http://nginx.org/en/docs/http/ngx_http_auth_request_module.html

--
Roman Arutyunyan
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Loading...