Fredrik Widlund
June 23, 2011 11:54AM
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;

off_t max_temp_file_size;
ssize_t temp_file_write_size;

_
_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Problem with upstream server

Fredrik Widlund June 23, 2011 11:54AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 178
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready