tarantool / nginx_upstream_module

Tarantool NginX upstream module (REST, JSON API, websockets, load balancing)
Other
174 stars 18 forks source link

Invalid encoding of response body from upstream #94

Closed ja1cap closed 7 years ago

ja1cap commented 7 years ago

Checked versions: v2.3.7 and v2.4.6-rc1

nginx -V

nginx version: nginx/1.11.10
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.0.2j-fips  26 Sep 2016
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error_log --http-log-path=/var/log/nginx --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_geoip_module --with-http_realip_module --without-http_ssi_module --without-http_userid_module --without-http_referer_module --without-http_uwsgi_module --without-http_scgi_module --without-http_memcached_module --without-http_browser_module --without-http_upstream_ip_hash_module --without-http_upstream_least_conn_module --with-http_gunzip_module --add-module=./ngx_devel_kit-0.3.0/ --add-module=./lua-nginx-module-0.10.7 --add-module=./ngx_dynamic_upstream-0.1.6 --add-dynamic-module=./nginx-module-vts-0.1.11 --add-dynamic-module=./nginx_upstream_module-2.3.7 --add-dynamic-module=./src --with-pcre-jit

nginx config

server {
  location = /test.php {
    lua_need_request_body on;
    rewrite_by_lua '
      local res = ngx.location.capture("/tnt_procudure", { args = ngx.var.args })
      ngx.req.set_header("Content-Type", "application/json")
      ngx.log(ngx.INFO, res.body)
      ngx.req.set_body_data(res.body)
    ';
    include php7.conf;
  }
  location = /tnt_procudure {
    proxy_pass                  http://tarantool_nginx:8080/tnt_procudure;
    proxy_set_header            Host $host;
  }
}

upstream tarantool_backend {
  server localhost:3301;
}

server {

  default_type application/json; charset UTF-8;

  listen       8080;
  location / {
    tnt_http_rest_methods get post put delete;
    tnt_pure_result on;
    tnt_pass tarantool_backend;
  }

  location /tnt_procudure {
    tnt_http_rest_methods get post put delete;
    tnt_pure_result on;
    tnt_pass_http_request on parse_args;
    tnt_pass tarantool_backend;
  }

}

Upstream response

* About to connect() to localhost port 8080 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /tnt_procudure HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8080
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: nginx
< Date: Wed, 26 Jul 2017 09:38:43 GMT
< Content-Type: application/json
< Transfer-Encoding: chunked
< Connection: keep-alive
< Vary: Accept-Encoding
< 
* Connection #0 to host localhost left intact
[{"ids":[323],"debug_messages":[],"rejected_ids":[]}]

nginx.log terminal

tarantool -V

Tarantool 1.7.3-670-g323f33b
Target: Linux-x86_64-RelWithDebInfo
Build options: cmake . -DCMAKE_INSTALL_PREFIX=/usr -DENABLE_BACKTRACE=ON
Compiler: /opt/rh/devtoolset-6/root/usr/bin/cc /opt/rh/devtoolset-6/root/usr/bin/c++
C_FLAGS:-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2 -std=c11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -fno-gnu89-inline
CXX_FLAGS:-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches   -m64 -mtune=generic  -fexceptions -funwind-tables -fno-omit-frame-pointer -fno-stack-protector -fno-common -fopenmp -msse2 -std=c++11 -Wall -Wextra -Wno-strict-aliasing -Wno-char-subscripts -Wno-format-truncation -Wno-invalid-offsetof