Hello all!
We are glad to share with first results of our ongoing efforts to create
documentation for nginx developers: the development guide document [1].
The guide is not yet 100% complete and more parts to follow.
Of course, your feedback is welcome.
[1] http://nginx.org/en/docs/dev/development_guide.html
# HG changeset patch
# User Nate Karstens <nate.karstens at garmin.com>
# Date 1493467011 18000
# Sat Apr 29 06:56:51 2017 -0500
# Node ID 1251a543804b17941b2c96b84bd1f4e58a37bc15
# Parent 8801ff7d58e1650c9d1abb50e09f5979e4f9ffbf
Proxy: support configuration of socket buffer sizes
Allows the size of the buffers used by the TCP sockets
for HTTP proxy connections to be configured. The new
configuration directives are:
* proxy_socket_rcvbuf
* proxy_socket_sndbuf
These correspond with the SO_RCVBUF and SO_SNDBUF socket
options, respectively.
This is be useful in cases where the proxy processes
received data slowly. Data was being buffered in three
separate TCP buffers (nginx-from-client receive, nginx-
to-proxy send, and proxy-from-nginx receive). The
cumulative effect is that the client thinks it has
sent all of the data, but times out waiting for a reply
from the proxy, which cannot reply because it is still
processing the data in its buffers.
Signed-off-by: Nate Karstens <nate.karstens at garmin.com>
diff -r 8801ff7d58e1 -r 1251a543804b src/event/ngx_event_connect.c
--- a/src/event/ngx_event_connect.c Tue Apr 25 23:39:13 2017 +0300
+++ b/src/event/ngx_event_connect.c Sat Apr 29 06:56:51 2017 -0500
@@ -73,6 +73,16 @@
}
}
+ if (pc->sndbuf) {
+ if (setsockopt(s, SOL_SOCKET, SO_SNDBUF,
+ (const void *) &pc->sndbuf, sizeof(int)) == -1)
+ {
+ ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
+ "setsockopt(SO_SNDBUF) failed");
+ goto failed;
+ }
+ }
+
if (ngx_nonblocking(s) == -1) {
ngx_log_error(NGX_LOG_ALERT, pc->log, ngx_socket_errno,
ngx_nonblocking_n " failed");
diff -r 8801ff7d58e1 -r 1251a543804b src/event/ngx_event_connect.h
--- a/src/event/ngx_event_connect.h Tue Apr 25 23:39:13 2017 +0300
+++ b/src/event/ngx_event_connect.h Sat Apr 29 06:56:51 2017 -0500
@@ -57,6 +57,7 @@
int type;
int rcvbuf;
+ int sndbuf;
ngx_log_t *log;
diff -r 8801ff7d58e1 -r 1251a543804b src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c Tue Apr 25 23:39:13 2017 +0300
+++ b/src/http/modules/ngx_http_proxy_module.c Sat Apr 29 06:56:51 2017 -0500
@@ -90,6 +90,9 @@
ngx_uint_t headers_hash_max_size;
ngx_uint_t headers_hash_bucket_size;
+ ngx_int_t rcvbuf;
+ ngx_int_t sndbuf;
+
#if (NGX_HTTP_SSL)
ngx_uint_t ssl;
ngx_uint_t ssl_protocols;
@@ -629,6 +632,20 @@
offsetof(ngx_http_proxy_loc_conf_t, http_version),
&ngx_http_proxy_http_version },
+ { ngx_string("proxy_socket_rcvbuf"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_proxy_loc_conf_t, rcvbuf),
+ NULL },
+
+ { ngx_string("proxy_socket_sndbuf"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
+ ngx_conf_set_num_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_proxy_loc_conf_t, sndbuf),
+ NULL },
+
#if (NGX_HTTP_SSL)
{ ngx_string("proxy_ssl_session_reuse"),
@@ -905,6 +922,13 @@
u->buffering = plcf->upstream.buffering;
+ if (plcf->rcvbuf != NGX_CONF_UNSET) {
+ u->peer.rcvbuf = plcf->rcvbuf;
+ }
+ if (plcf->sndbuf != NGX_CONF_UNSET) {
+ u->peer.sndbuf = plcf->sndbuf;
+ }
+
u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
if (u->pipe == NULL) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
@@ -2902,6 +2926,9 @@
conf->headers_hash_max_size = NGX_CONF_UNSET_UINT;
conf->headers_hash_bucket_size = NGX_CONF_UNSET_UINT;
+ conf->rcvbuf = NGX_CONF_UNSET;
+ conf->sndbuf = NGX_CONF_UNSET;
+
ngx_str_set(&conf->upstream.module, "proxy");
return conf;
@@ -3297,6 +3324,12 @@
ngx_conf_merge_uint_value(conf->headers_hash_bucket_size,
prev->headers_hash_bucket_size, 64);
+ ngx_conf_merge_value(conf->rcvbuf,
+ prev->rcvbuf, NGX_CONF_UNSET);
+
+ ngx_conf_merge_value(conf->sndbuf,
+ prev->sndbuf, NGX_CONF_UNSET);
+
conf->headers_hash_bucket_size = ngx_align(conf->headers_hash_bucket_size,
ngx_cacheline_size);
________________________________
CONFIDENTIALITY NOTICE: This email and any attachments are for the sole use of the intended recipient(s) and contain information that may be Garmin confidential and/or Garmin legally privileged. If you have received this email in error, please notify the sender by reply email and delete the message. Any disclosure, copying, distribution or use of this communication (including attachments) by someone other than the intended recipient is prohibited. Thank you.
details: http://hg.nginx.org/nginx/rev/aeaac3ccee4f
branches:
changeset: 7043:aeaac3ccee4f
user: Maxim Dounin <mdounin(a)mdounin.ru>
date: Tue Jun 27 00:53:46 2017 +0300
description:
Range filter: allowed ranges on empty files (ticket #1031).
As per RFC 2616 / RFC 7233, any range request to an empty file
is expected to result in 416 Range Not Satisfiable response, as
there cannot be a "byte-range-spec whose first-byte-pos is less
than the current length of the entity-body". On the other hand,
this makes use of byte-range requests inconvenient in some cases,
as reported for the slice module here:
http://mailman.nginx.org/pipermail/nginx-devel/2017-June/010177.html
This commit changes range filter to instead return 200 if the file
is empty and the range requested starts at 0.
diffstat:
src/http/modules/ngx_http_range_filter_module.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diffs (13 lines):
diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c
--- a/src/http/modules/ngx_http_range_filter_module.c
+++ b/src/http/modules/ngx_http_range_filter_module.c
@@ -382,6 +382,9 @@ ngx_http_range_parse(ngx_http_request_t
if (ranges-- == 0) {
return NGX_DECLINED;
}
+
+ } else if (start == 0) {
+ return NGX_DECLINED;
}
if (*p++ != ',') {
details: http://hg.nginx.org/nginx/rev/5e05118678af
branches:
changeset: 7011:5e05118678af
user: Roman Arutyunyan <arut(a)nginx.com>
date: Mon May 29 23:33:38 2017 +0300
description:
Fixed background requests with asynchronous operations.
If the main request was finalized while a background request performed an
asynchronous operation, the main request ended up in ngx_http_writer() and was
not finalized until a network event or a timeout. For example, cache
background update with aio enabled made nginx unable to process further client
requests or close the connection, keeping it open until client closes it.
Now regular finalization of the main request is not suspended because of an
asynchronous operation in another request.
If a background request was terminated while an asynchronous operation was in
progress, background request's write event handler was changed to
ngx_http_request_finalizer() and never called again.
Now, whenever a request is terminated while an asynchronous operation is in
progress, connection error flag is set to make further finalizations of any
request with this connection lead to termination.
These issues appeared in 1aeaae6e9446 (not yet released).
diffstat:
src/http/ngx_http_request.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diffs (32 lines):
diff -r c1524829af3d -r 5e05118678af src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c Mon May 29 16:48:30 2017 +0300
+++ b/src/http/ngx_http_request.c Mon May 29 23:33:38 2017 +0300
@@ -2331,10 +2331,6 @@ ngx_http_finalize_request(ngx_http_reque
return;
}
- if (r->main->blocked) {
- r->write_event_handler = ngx_http_request_finalizer;
- }
-
ngx_http_terminate_request(r, rc);
return;
}
@@ -2449,7 +2445,7 @@ ngx_http_finalize_request(ngx_http_reque
return;
}
- if (r->buffered || c->buffered || r->postponed || r->blocked) {
+ if (r->buffered || c->buffered || r->postponed) {
if (ngx_http_set_write_handler(r) != NGX_OK) {
ngx_http_terminate_request(r, 0);
@@ -2530,6 +2526,8 @@ ngx_http_terminate_request(ngx_http_requ
if (mr->write_event_handler) {
if (mr->blocked) {
+ r->connection->error = 1;
+ r->write_event_handler = ngx_http_request_finalizer;
return;
}
Add new directive '2square' to image_filter, which resizes and converts
image in square and add white border. It's cood be usefull for convert
image for facebook banners.
In attach:
nginx.patch - patch for main repo (http://hg.nginx.org/nginx),
image_filter_2square.t - file with tests for (http://hg.nginx.org/nginx-
tests)
nginx_org.patch - docs for (http://hg.nginx.org/nginx.org/)
--
С уважением,
Иванов Иван
--
С уважением,
Иванов Иван