# Nginx 1.8 proxying to Netty - timeout from upstream

**URL:** <https://www.ruby-forum.com/t/nginx-1-8-proxying-to-netty-timeout-from-upstream/242720>\
**Category:** NGINX\
**Created:** [July 21, 2015, 9:33pm UTC](https://www.ruby-forum.com/t/nginx-1-8-proxying-to-netty-timeout-from-upstream/242720 "2015-07-21T21:33:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [July 21, 2015, 9:33pm UTC](https://www.ruby-forum.com/t/nginx-1-8-proxying-to-netty-timeout-from-upstream/242720/1 "2015-07-21T21:33:52Z")

</div>

I have setup Nginx proxy to a Netty server. I am seeing a timeout from  
upstream, i.e. Netty. The consequence of this timeout is that the JSON  
payload response is truncated (as seen on browser developer tools)

2015/07/21 05:08:56 [error] 6#0: \*19 upstream prematurely closed  
connection  
while reading upstream, client: 198.147.191.15, server:  
[sbox-wus-ui.cloudapp.net](http://sbox-wus-ui.cloudapp.net), request: “GET /api/v1/entities/DEVICE  
HTTP/1.1”,  
upstream: “[http://10.0.3.4:8080/api/v1/entities/DEVICE](http://10.0.3.4:8080/api/v1/entities/DEVICE)”, host:  
“[sbox-wus-ui.cloudapp.net](http://sbox-wus-ui.cloudapp.net)”, referrer:  
“[https://sbox-wus-ui.cloudapp.net/home.html](https://sbox-wus-ui.cloudapp.net/home.html)”

So, yes I initially thought that this is a Netty issue. However, when I  
make  
the same API call on Netty I am able to the retrieve the full JSON  
payload.

The JSON response message size is about 13k. The JSON response I see on  
the  
Nginx side is 10K. After spending some time reading up on the Nginx  
configuration parameters, I added client\_body\_temp and proxy\_temp but to  
no  
avail. Any help is really appreciated.

Nginx details:

nginx version: nginx/1.8.0  
built by gcc 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC)  
built with OpenSSL 1.0.1e-fips 11 Feb 2013  
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/access.log --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  
–http-uwsgi-temp-path=/var/cache/nginx/uwsgi\_temp  
–http-scgi-temp-path=/var/cache/nginx/scgi\_temp --user=nginx  
–group=nginx  
–with-http\_ssl\_module --with-http\_realip\_module  
–with-http\_addition\_module  
–with-http\_sub\_module --with-http\_dav\_module --with-http\_flv\_module  
–with-http\_mp4\_module --with-http\_gunzip\_module  
–with-http\_gzip\_static\_module --with-http\_random\_index\_module  
–with-http\_secure\_link\_module --with-http\_stub\_status\_module  
–with-http\_auth\_request\_module --with-mail --with-mail\_ssl\_module  
–with-file-aio --with-ipv6 --with-http\_spdy\_module --with-cc-opt=‘-O2  
-g  
-pipe -Wp,-D\_FORTIFY\_SOURCE=2 -fexceptions -fstack-protector  
–param=ssp-buffer-size=4 -m64 -mtune=generic’

* * *

# For more information on configuration, see:

# \* Official English Documentation: [nginx documentation](http://nginx.org/en/docs/)

# \* Official Russian Documentation: [nginx: документация](http://nginx.org/ru/docs/)

user nginx;  
worker\_processes 1;  
daemon off;

error\_log {{logDir}}/error.log;

pid /run/nginx.pid;

events {  
worker\_connections 1024;  
}

http {  
include /etc/nginx/mime.types;  
default\_type application/octet-stream;

```
log_format main '$remote_addr - $remote_user [$time_local] 

```

“$request”  
’  
'$status $body\_bytes\_sent “$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;

```
access_log {{logDir}}/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;

chunked_transfer_encoding off;

# Disable constraints on potential large uploads resulting in HTTP 

```

413

# 

```
client_max_body_size 0;

#gzip on;

index index.html index.htm;

upstream netty { {% for netty in servers %}
     server {{netty}}; {% endfor %}
}

# Load modular configuration files from the /etc/nginx/conf.d

```

directory.  
# See [Core functionality](http://nginx.org/en/docs/ngx_core_module.html#include)  
# for more information.  
include /etc/nginx/conf.d/\*.conf;

server {  
listen 80;  
server\_name {{serverName}};  
rewrite ^ https://$server\_name$request\_uri? permanent;  
}

```
server {
    listen 443 ssl;
    server_name {{serverName}};

```

ssl\_certificate /data/nginx/cert/{{crtFile}};  
ssl\_certificate\_key /data/nginx/cert/{{keyFile}};

```
    root /usr/share/nginx/html;

    #charset koi8-r;

    #access_log /var/log/nginx/host.access.log main;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

#The only resource available to check health
location /health {
  root /apps/nginx/f2;
     index index.html;
  }

    location / {
          client_body_buffer_size 128k;

        client_body_temp_path /apps/nginx/client_body_temp;

        proxy_connect_timeout 90;
        proxy_send_timeout 90;
        proxy_read_timeout 90;

        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
  proxy_temp_path /apps/nginx/proxy_temp;
  root /apps/nginx/f2;
     index index.html;
     {% if basicAuth == "true" %}
       auth_basic "Restricted";
      auth_basic_user_file /data/nginx/cert/htpasswd;
     {% endif %}
}

location /ui/ {
  proxy_pass http://netty;
  {% if basicAuth == "true" %}
       auth_basic "Restricted";
      auth_basic_user_file /data/nginx/cert/htpasswd;
     {% endif %}
  }

location /api/ {
  proxy_pass http://netty;
   }

   location /sales/ {
  root /apps/nginx/f2;
     index index.html;
     {% if basicAuth == "true" %}
       auth_basic "Restricted";
      auth_basic_user_file /data/nginx/cert/htpasswd;
     {% endif %}
   }

    # redirect server error pages to the static page /40x.html
    #
    error_page 404 /404.html;
    location = /40x.html {
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}

```

}

Posted at Nginx Forum:

> **[Nginx 1.8 proxying to Netty - timeout from upstream](https://forum.nginx.org/read.php?2,260455,260455#msg-260455)**
>
> I have setup Nginx proxy to a Netty server. I am seeing a timeout from upstream, i.e. Netty. The consequence of this timeout is that the JSON payload response is truncated (as seen on browser developer tools) 2015/07/21 05:08:56 \[error\] 6#0: \*19...

---

<div class="post-metadata">

**Author:** ![smuthali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f05b48/32.png) [@smuthali](https://www.ruby-forum.com/u/smuthali)\
**Post date:** [July 22, 2015, 11:55pm UTC](https://www.ruby-forum.com/t/nginx-1-8-proxying-to-netty-timeout-from-upstream/242720/2 "2015-07-22T23:55:53Z")

</div>

Hello!

On Tue, Jul 21, 2015 at 03:33:13PM -0400, smuthali wrote:

> So, yes I initially thought that this is a Netty issue. However, when I make  
> the same API call on Netty I am able to the retrieve the full JSON payload.
> 
> The JSON response message size is about 13k. The JSON response I see on the  
> Nginx side is 10K. After spending some time reading up on the Nginx  
> configuration parameters, I added client\_body\_temp and proxy\_temp but to no  
> avail. Any help is really appreciated.

The message suggests this is a backend problem. If you don’t see  
the problem by directly talking to the backend - this may be  
because the problem only appears in some specific conditions  
triggered by nginx, e.g., only when HTTP/1.0 is used.

If in doubt, try looking in nginx debug log and/or tcpdump to find  
out what’s going on on the wire.

–  
Maxim D.

> **[nginx](http://nginx.org/)**

---

<div class="post-metadata">

**Author:** ![smuthali](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f05b48/32.png) [@smuthali](https://www.ruby-forum.com/u/smuthali)\
**Post date:** [July 23, 2015, 5:46pm UTC](https://www.ruby-forum.com/t/nginx-1-8-proxying-to-netty-timeout-from-upstream/242720/3 "2015-07-23T17:46:49Z")

</div>

Maxim, many thanks for the reply. i did run a tcpdump on nginx port 8080  
and  
dst being Netty. I did not see anything out the ordinary in the packet  
capture. Essentially i see a HTTP 200 OK for response and the  
connections  
are torn down as expected. I wil run another packet capture just in  
case I  
overlooked something.

Thanks again.

Satish

Posted at Nginx Forum:

> **[Re: Nginx 1.8 proxying to Netty - timeout from upstream](https://forum.nginx.org/read.php?2,260455,260522#msg-260522)**
>
> I have setup Nginx proxy to a Netty server. I am seeing a timeout from upstream, i.e. Netty. The consequence of this timeout is that the JSON payload response is truncated (as seen on browser developer tools) 2015/07/21 05:08:56 \[error\] 6#0: \*19...
