HTTP request / response with response from a different server

nha

In an HTTP request/response scenario, I guess it doesn't matter to the client who responds to the requests (how would he tell anyway).

In short, I want to go from this :

Client
 ↓   ↑
 Nginx
  ↓   ↑
  ServerA
   ↓   ↑
   ServerB

To this :

Client
 ↓    ↑
 Nginx ↖
  ↓      ↖
  ServerA  ↖
   ↓      ↗
   ServerB

Since serverB already has the response and no additional treatment will be done, I would like to bypass the serverA, but should go through nginx if possible (to use compression for instance).

Specifically I would like to know more about :

  • the nginx configuration necessary (if any)

  • does the protocol exchange between serverA and ServerB has to be special ?

  • the context that has to be passed around for this to happen ? Also, what happens if they use different languages (in my case Clojure and Scala).

A small sample example would be very welcome (preferably Clojure, Scala, Java, Node.js - any language as long as it's readable).

xfeep

I'm sure your case can be implemented with nginx-clojure. Last year somebody did similar but more complex things with nginx-clojure. And there 's nothing to do with protocol exchange between serverA and ServerB.

  1. in nginx content handler, use hijack! to get a NginxHttpServerChannel say ch, put ch into a map with key say req-uuid. So we can use ch to send response data later. Sends nginx url, req-uuid and other data to ServerA.
  2. ServerA sends nginx-url, req-uuid and other data to ServerB.
  3. ServerB sends req-uuid and response to nginx by another url which is different with the first step, e.g. '/asynNotfifyHandler'
  4. write another nginx content handler to receive response from ServerB for location '/asynNotfifyHandler'. If nginx worker process is only one, in this handler gets NginxHttpServerChannel ch and uses it to send the response. If we have more than one nginx worker processes we need use broadcast! to broadcast repsonse event and use on-broadcast! to get the response event in the nginx worker process who holds the NginxHttpServerChannel ch and use it to send the response to the original client.

Here is an example about channel sub/pub.

BTW We also can use sub/pub from redis instead of broadcast! and on-broadcast! from nginx-clojure. e.g. in the first content handler we sub a topic of redis and then server B pub a response message to the same topic of redis. Finally use NginxHttpServerChannel ch to send the response to the original client.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

HTTP Request Response in Different Flow

From Dev

HTTP Request Response in Different Flow

From Dev

HTTP Response content type different on HEAD request

From Dev

expressjs server http request returning empty response

From Dev

HTTP server send new request with response

From Dev

HTTP Request with No HTTP Response

From Dev

HTTP Request with No HTTP Response

From Dev

Http request and response lost after receiving Response from Web Service?

From Dev

loop through the response from a HTTP request Angular

From Dev

loop through the response from a HTTP request Angular

From Dev

PHP Response to HTTP Request From Android

From Dev

Change Response from HTTP Request sent by a program

From Dev

Incorrect response from the server anfter GET request

From Dev

412 Server Response Code from $.ajax Request

From Dev

HTTP request/response flow

From Dev

HTTP request/response flow

From Dev

HTTP request and response messages

From Dev

How is the HTTP version of a browser request and the HTTP version of a server response determined?

From Dev

Print response JSON from server with HTTP POST

From Dev

Why cURL response from server is HTTP/1.0?

From Dev

how to get the server name from a http response

From Dev

Send HTTP Response from we server to client

From Dev

Play framework make http request from play server to "somesite.com" and send the response back to the browser

From Dev

How can I see the server response from an HTTP GET request in Swift?

From Dev

Read HTTP response header and body from one HTTP request in java

From Dev

Response of ajax request is different on my local environment and my live server

From Dev

Call new request only if response of previous request returns from server

From Dev

HTTP Response Header to identify actual server that responded to request

From Dev

Server returned HTTP response code: 500 for URL for GET request

Related Related

  1. 1

    HTTP Request Response in Different Flow

  2. 2

    HTTP Request Response in Different Flow

  3. 3

    HTTP Response content type different on HEAD request

  4. 4

    expressjs server http request returning empty response

  5. 5

    HTTP server send new request with response

  6. 6

    HTTP Request with No HTTP Response

  7. 7

    HTTP Request with No HTTP Response

  8. 8

    Http request and response lost after receiving Response from Web Service?

  9. 9

    loop through the response from a HTTP request Angular

  10. 10

    loop through the response from a HTTP request Angular

  11. 11

    PHP Response to HTTP Request From Android

  12. 12

    Change Response from HTTP Request sent by a program

  13. 13

    Incorrect response from the server anfter GET request

  14. 14

    412 Server Response Code from $.ajax Request

  15. 15

    HTTP request/response flow

  16. 16

    HTTP request/response flow

  17. 17

    HTTP request and response messages

  18. 18

    How is the HTTP version of a browser request and the HTTP version of a server response determined?

  19. 19

    Print response JSON from server with HTTP POST

  20. 20

    Why cURL response from server is HTTP/1.0?

  21. 21

    how to get the server name from a http response

  22. 22

    Send HTTP Response from we server to client

  23. 23

    Play framework make http request from play server to "somesite.com" and send the response back to the browser

  24. 24

    How can I see the server response from an HTTP GET request in Swift?

  25. 25

    Read HTTP response header and body from one HTTP request in java

  26. 26

    Response of ajax request is different on my local environment and my live server

  27. 27

    Call new request only if response of previous request returns from server

  28. 28

    HTTP Response Header to identify actual server that responded to request

  29. 29

    Server returned HTTP response code: 500 for URL for GET request

HotTag

Archive