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
Hello!
I'd like to see few more lines about SHA-2 support in glibc crypt() in
documentation. I've created small patch for nginx.org repo, it's
attached.
--
WBRBW, Leonid Evdokimov, xmpp:leon@darkk.net.ru http://darkk.net.ru tel:+79816800702
PGP: 6691 DE6B 4CCD C1C1 76A0 0D4A E1F2 A980 7F50 FAB2
Hi
I saw there's an issue talking about "implement keepalive timeout for
upstream <https://trac.nginx.org/nginx/ticket/1170>".
I have a different scenario for this requirement.
I'm using Node.js web server as upstream, and set keep alive time out to 60
second in nodejs server. The problem is I found more than a hundred
"Connection reset by peer" errors everyday.
Because there's no any errors on nodejs side, I guess it was because of the
upstream has disconnected, and at the same time, nginx send a new request,
then received a TCP RST.
I tried Tengine <http://tengine.taobao.org/> which is a taobao cloned
version of nginx, and set upstream keep alive timeout to 30s, then there's
no errors any more.
So I want to know is there any plan to work on this enhancement? or can I
submit a patch for it?
Best Regards
Wei Xu
# 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.
# HG changeset patch
# User Gena Makhomed <gmm(a)csdoc.com>
# Date 1511951401 -7200
# Wed Nov 29 12:30:01 2017 +0200
# Node ID b529ea784244e13d8a5e58a12c8b639351652057
# Parent fc0d06224edac2c7cfbfd9a4def478f285d9957b
Workaround for systemd error messages about nginx pid file.
Race condition exists between nginx writing and systemd reading pid file.
Sometimes systemd can produce error messages about nginx pid file:
systemd: Failed to read PID from file /var/run/nginx.pid: Invalid argument
systemd: PID file /var/run/nginx.pid not readable (yet?) after start.
This patch add small delay before nginx original process exit
to eliminate race condition between nginx and systemd.
diff -r fc0d06224eda -r b529ea784244 src/os/unix/ngx_daemon.c
--- a/src/os/unix/ngx_daemon.c Tue Nov 28 13:09:54 2017 +0300
+++ b/src/os/unix/ngx_daemon.c Wed Nov 29 12:30:01 2017 +0200
@@ -23,6 +23,7 @@
break;
default:
+ ngx_msleep(100);
exit(0);
}