|
| 1 | +# nginx_upstream_module |
| 2 | +Tarantool NginX upstream module (JSON API, websockets, load balancing) |
| 3 | + |
| 4 | + Key features: |
| 5 | + * United nginx features and tarantool features over HTTP(S). |
| 6 | + * Call tarantool methods via json rpc. |
| 7 | + |
| 8 | + About tarantool: http://tarantool.org |
| 9 | + |
| 10 | + About upstream: http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream |
| 11 | + |
| 12 | +## Protocol |
| 13 | + |
| 14 | + Module expectes json posted over HTTP POST in request body. |
| 15 | + |
| 16 | +### Input JSON form |
| 17 | + |
| 18 | + { "method": METHOD_NAME, "params":[TNT_METHOD, arg0 ... argN], "id": ID } |
| 19 | + |
| 20 | + "method" |
| 21 | + |
| 22 | + A String containing the name of the method to be invoked, |
| 23 | + i.e. Tarantool "call", "eval", etc. |
| 24 | + |
| 25 | + Notice. Only tarantool "call" method is supported. |
| 26 | + |
| 27 | + "params" |
| 28 | + |
| 29 | + Here is a Structured array, that MUST hold the TNT_METHOD name as first element before all of the rest elements. |
| 30 | + These elements are arguments of TNT_METHOD. |
| 31 | + |
| 32 | + "id" |
| 33 | + An identifier established by the Client MUST contain an unsigned Number not |
| 34 | + greater than unsigned int. |
| 35 | + |
| 36 | + These are required fields. |
| 37 | + |
| 38 | +### Output JSON form |
| 39 | + |
| 40 | + { "result": JSON_RESULT_OBJECT, "id" ID, "error": { "message": STR } } |
| 41 | + |
| 42 | + "result" |
| 43 | + |
| 44 | + Tarantool executing result as json object/array etc. |
| 45 | + MAY be null or undefined. |
| 46 | + |
| 47 | + "id" |
| 48 | + |
| 49 | + Request id is returned back. |
| 50 | + MAY be null or undefined in case of internal error. |
| 51 | + |
| 52 | + |
| 53 | + "error" |
| 54 | + |
| 55 | + Here is a Structured object which contains internal error message. |
| 56 | + This field exists only if internal error occured, for instance "too large |
| 57 | + request", "input json parse error", etc. |
| 58 | + |
| 59 | + If this field exists input message did not pass to Tarantool backend. |
| 60 | + |
| 61 | + See "message" field for details. |
| 62 | + |
| 63 | + |
| 64 | +## Compilation and install |
| 65 | + |
| 66 | +### Build from the sources |
| 67 | + |
| 68 | + $ cd REPO_ROOT |
| 69 | + $ git submodule init |
| 70 | + $ git submodule update |
| 71 | + $ git clone https://github.com/nginx/nginx.git nginx |
| 72 | + $ make build-all # build-all-debug i.e. debug version |
| 73 | + |
| 74 | +### Build module via nginx 'configure' |
| 75 | + |
| 76 | + Requirements (for details see REPO_ROOT/Makefile) |
| 77 | + |
| 78 | + libyajl >= 2.0(https://lloyd.github.io/yajl/) |
| 79 | + libtp (https://github.com/tarantool/tarantool-c) |
| 80 | + |
| 81 | + $ ./configure --add-module=REPO_ROOT && make |
| 82 | + |
| 83 | +## Configuration |
| 84 | + |
| 85 | +```nginx |
| 86 | +
|
| 87 | + upstream backend { |
| 88 | + server 127.0.0.1:9999; |
| 89 | + # ... |
| 90 | + } |
| 91 | +
|
| 92 | + server { |
| 93 | + location = /tnt { |
| 94 | + tnt_pass backend; |
| 95 | + } |
| 96 | + } |
| 97 | +
|
| 98 | +``` |
| 99 | + |
| 100 | +Please report bugs at https://github.com/tarantool/nginx_upstream_module/issues |
| 101 | +We also warmly welcome your feedback in the discussion mailing list, tarantool@googlegroups.com. |
0 commit comments