# Problem with upstream server

**URL:** <https://www.ruby-forum.com/t/problem-with-upstream-server/208662>\
**Category:** NGINX\
**Created:** [June 23, 2011, 5:52pm UTC](https://www.ruby-forum.com/t/problem-with-upstream-server/208662 "2011-06-23T17:52:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [June 23, 2011, 5:52pm UTC](https://www.ruby-forum.com/t/problem-with-upstream-server/208662/1 "2011-06-23T17:52:53Z")

</div>

Hi,

I am having some problems with a reverse proxy setup against a somewhat  
problematic commercial upstream server. The problem is that the server  
does not close the session after delivering the http object, and  
typically terminates the session 10 seconds later. Running something  
like curl will retrieve the object immediately while putting a rev nginx  
proxy in front delays the delivery with the 10 secs.

The “issue” I’m having with the proxy module is that it doesn’t consider  
the request done having read the full content-length of data when in  
buffered mode.

I dug around and made a ad-hoc quick fix patch for myself that does seem  
to solve the issue in my case but might break some other case. I’m not  
familiar enough with the code and don’t have enough time right now to  
solve it properly, but if nothing else it will illustrate what I want to  
achieve. If there is any out of the box way to achieve this please let  
me know. (I do need buffered mode, so using non-buffered is not an  
option)

Regards,  
Fredrik Widlund

— ngx\_http\_upstream-old.c 2011-06-23 18:54:22.000000000 +0200  
+++ ngx\_http\_upstream.c 2011-06-23 18:54:35.000000000 +0200  
@@ -1922,6 +1922,7 @@  
u-\>length = NGX\_MAX\_SIZE\_T\_VALUE;  
}

- u-\>pipe-\>read\_length\_expected = u-\>length;  
return NGX\_OK;  
}

— ngx\_event\_pipe-old.c 2011-06-23 18:50:32.000000000 +0200  
+++ ngx\_event\_pipe.c 2011-06-23 18:51:32.000000000 +0200  
@@ -301,6 +301,9 @@  
}

```
     p->read_length += n;

```

- 

```
   if (p->read_length_expected > 0 && p->read_length >= 

```

p-\>read\_length\_expected)

- 

```
       p->upstream_eof =1 ;

```

- 

```
   cl = chain;
   p->free_raw_bufs = NULL;

```

— ngx\_event\_pipe-old.h 2011-06-23 18:50:51.000000000 +0200  
+++ ngx\_event\_pipe.h 2011-06-23 18:51:59.000000000 +0200  
@@ -65,6 +65,7 @@  
ssize\_t busy\_size;

```
 off_t read_length;

```

- off\_t read\_length\_expected;

\_
