[nginx] Style.
details: http://hg.nginx.org/nginx/rev/ac52b46ebab5 branches: changeset: 6166:ac52b46ebab5 user: Maxim Dounin date: Fri Jun 05 17:10:34 2015 +0300 description: Style. diffstat: src/event/ngx_event.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diffs (14 lines): diff --git a/src/event/ngx_event.c b/src/event/ngx_event.c --- a/src/event/ngx_event.c +++ b/src/event/ngx_event.c @@ -927,8 +927,9 @@ ngx_events_block(ngx_conf_t *cf, ngx_com *cf = pcf; -if (rv != NGX_CONF_OK) +if (rv != NGX_CONF_OK) { return rv; +} for (i = 0; ngx_modules[i]; i++) { if (ngx_modules[i]->type != NGX_EVENT_MODULE) { ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[nginx] Upstream keepalive: reduced diffs to the plus version of...
details: http://hg.nginx.org/nginx/rev/87d48f8793b6 branches: changeset: 6167:87d48f8793b6 user: Roman Arutyunyan date: Thu Jun 04 23:46:44 2015 +0300 description: Upstream keepalive: reduced diffs to the plus version of nginx. diffstat: src/http/modules/ngx_http_upstream_keepalive_module.c | 81 +- 1 files changed, 42 insertions(+), 39 deletions(-) diffs (149 lines): diff -r ac52b46ebab5 -r 87d48f8793b6 src/http/modules/ngx_http_upstream_keepalive_module.c --- a/src/http/modules/ngx_http_upstream_keepalive_module.c Fri Jun 05 17:10:34 2015 +0300 +++ b/src/http/modules/ngx_http_upstream_keepalive_module.c Thu Jun 04 23:46:44 2015 +0300 @@ -25,6 +25,18 @@ typedef struct { typedef struct { ngx_http_upstream_keepalive_srv_conf_t *conf; +ngx_queue_tqueue; +ngx_connection_t *connection; + +socklen_t socklen; +u_char sockaddr[NGX_SOCKADDRLEN]; + +} ngx_http_upstream_keepalive_cache_t; + + +typedef struct { +ngx_http_upstream_keepalive_srv_conf_t *conf; + ngx_http_upstream_t *upstream; void *data; @@ -40,18 +52,6 @@ typedef struct { } ngx_http_upstream_keepalive_peer_data_t; -typedef struct { -ngx_http_upstream_keepalive_srv_conf_t *conf; - -ngx_queue_tqueue; -ngx_connection_t *connection; - -socklen_t socklen; -u_char sockaddr[NGX_SOCKADDRLEN]; - -} ngx_http_upstream_keepalive_cache_t; - - static ngx_int_t ngx_http_upstream_init_keepalive_peer(ngx_http_request_t *r, ngx_http_upstream_srv_conf_t *us); static ngx_int_t ngx_http_upstream_get_keepalive_peer(ngx_peer_connection_t *pc, @@ -63,7 +63,6 @@ static void ngx_http_upstream_keepalive_ static void ngx_http_upstream_keepalive_close_handler(ngx_event_t *ev); static void ngx_http_upstream_keepalive_close(ngx_connection_t *c); - #if (NGX_HTTP_SSL) static ngx_int_t ngx_http_upstream_keepalive_set_session( ngx_peer_connection_t *pc, void *data); @@ -244,24 +243,28 @@ ngx_http_upstream_get_keepalive_peer(ngx ngx_queue_remove(q); ngx_queue_insert_head(&kp->conf->free, q); -ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, - "get keepalive peer: using connection %p", c); - -c->idle = 0; -c->sent = 0; -c->log = pc->log; -c->read->log = pc->log; -c->write->log = pc->log; -c->pool->log = pc->log; - -pc->connection = c; -pc->cached = 1; - -return NGX_DONE; +goto found; } } return NGX_OK; + +found: + +ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pc->log, 0, + "get keepalive peer: using connection %p", c); + +c->idle = 0; +c->sent = 0; +c->log = pc->log; +c->read->log = pc->log; +c->write->log = pc->log; +c->pool->log = pc->log; + +pc->connection = c; +pc->cached = 1; + +return NGX_DONE; } @@ -322,8 +325,9 @@ ngx_http_upstream_free_keepalive_peer(ng item = ngx_queue_data(q, ngx_http_upstream_keepalive_cache_t, queue); } +ngx_queue_insert_head(&kp->conf->cache, q); + item->connection = c; -ngx_queue_insert_head(&kp->conf->cache, q); pc->connection = NULL; @@ -470,10 +474,9 @@ ngx_http_upstream_keepalive_create_conf( * * conf->original_init_upstream = NULL; * conf->original_init_peer = NULL; + * conf->max_cached = 0; */ -conf->max_cached = 1; - return conf; } @@ -487,18 +490,10 @@ ngx_http_upstream_keepalive(ngx_conf_t * ngx_int_tn; ngx_str_t *value; -uscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module); - -if (kcf->original_init_upstream) { +if (kcf->max_cached) { return "is duplicate"; } -kcf->original_init_upstream = uscf->peer.init_upstream - ? uscf->peer.init_upstream - : ngx_http_upstream_init_round_robin; - -uscf->peer.init_upstream = ngx_http_upstream_init_keepalive; - /* read options */ value = cf->args->elts; @@ -514,5 +509,13 @@ ngx_http_upstream_keepalive(ngx_conf_t * kcf->max_cached = n; +uscf = ngx_http_conf_get_module_srv_conf(cf, ngx_http_upstream_module); + +kcf->original_init_upstream = uscf->peer.init_upstream + ? uscf->peer.init_upstream + : ngx_http_upstream_init_round_robin; + +uscf->peer.init_upstream = ngx_http_upstream_init_keepalive; + return NGX_CONF_OK; } ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[nginx] Added the REQUEST_SCHEME parameter.
details: http://hg.nginx.org/nginx/rev/62869a9b2e7d branches: changeset: 6168:62869a9b2e7d user: Maxim Dounin date: Fri Jun 05 22:23:26 2015 +0300 description: Added the REQUEST_SCHEME parameter. The REQUEST_SCHEME parameter was introduced in Apache 2.3.11 and seems to be used by some scripts now. It looks more logical than previously used HTTPS. diffstat: conf/fastcgi.conf | 1 + conf/fastcgi_params | 1 + conf/scgi_params| 1 + conf/uwsgi_params | 1 + 4 files changed, 4 insertions(+), 0 deletions(-) diffs (44 lines): diff --git a/conf/fastcgi.conf b/conf/fastcgi.conf --- a/conf/fastcgi.conf +++ b/conf/fastcgi.conf @@ -10,6 +10,7 @@ fastcgi_param REQUEST_URI$reque fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL$server_protocol; +fastcgi_param REQUEST_SCHEME $scheme; fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1; diff --git a/conf/fastcgi_params b/conf/fastcgi_params --- a/conf/fastcgi_params +++ b/conf/fastcgi_params @@ -9,6 +9,7 @@ fastcgi_param REQUEST_URI$reque fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param SERVER_PROTOCOL$server_protocol; +fastcgi_param REQUEST_SCHEME $scheme; fastcgi_param HTTPS $https if_not_empty; fastcgi_param GATEWAY_INTERFACE CGI/1.1; diff --git a/conf/scgi_params b/conf/scgi_params --- a/conf/scgi_params +++ b/conf/scgi_params @@ -8,6 +8,7 @@ scgi_param DOCUMENT_URI $document scgi_param DOCUMENT_ROOT $document_root; scgi_param SCGI 1; scgi_param SERVER_PROTOCOL$server_protocol; +scgi_param REQUEST_SCHEME $scheme; scgi_param HTTPS $https if_not_empty; scgi_param REMOTE_ADDR$remote_addr; diff --git a/conf/uwsgi_params b/conf/uwsgi_params --- a/conf/uwsgi_params +++ b/conf/uwsgi_params @@ -8,6 +8,7 @@ uwsgi_param REQUEST_URI$request uwsgi_param PATH_INFO $document_uri; uwsgi_param DOCUMENT_ROOT $document_root; uwsgi_param SERVER_PROTOCOL$server_protocol; +uwsgi_param REQUEST_SCHEME $scheme; uwsgi_param HTTPS $https if_not_empty; uwsgi_param REMOTE_ADDR$remote_addr; ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[PATCH] Adds $orig_remote_addr in realip module
# HG changeset patch # User Jon Nalley # Date 1433560679 18000 # Fri Jun 05 22:17:59 2015 -0500 # Node ID b7c07ccca1f9be7038379cfd1077fb5885b3f388 # Parent 62869a9b2e7d1b2b698cb1ca67ad664b37171113 Adds $orig_remote_addr in realip module. When the realip module sets $remote_addr, the connecting IP is no longer available for logging etc. This change preserves the connecting IP as $orig_remote_addr. diff -r 62869a9b2e7d -r b7c07ccca1f9 src/http/modules/ngx_http_realip_module.c --- a/src/http/modules/ngx_http_realip_module.c Fri Jun 05 22:23:26 2015 +0300 +++ b/src/http/modules/ngx_http_realip_module.c Fri Jun 05 22:17:59 2015 -0500 @@ -33,6 +33,10 @@ } ngx_http_realip_ctx_t; +static ngx_int_t +ngx_http_realip_orig_remote_addr_variable(ngx_http_request_t *r, +ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_realip_add_variables(ngx_conf_t *cf); static ngx_int_t ngx_http_realip_handler(ngx_http_request_t *r); static ngx_int_t ngx_http_realip_set_addr(ngx_http_request_t *r, ngx_addr_t *addr); @@ -75,7 +79,7 @@ static ngx_http_module_t ngx_http_realip_module_ctx = { -NULL, /* preconfiguration */ +ngx_http_realip_add_variables, /* preconfiguration */ ngx_http_realip_init, /* postconfiguration */ NULL, /* create main configuration */ @@ -105,6 +109,15 @@ }; +static ngx_http_variable_t ngx_http_realip_vars[] = { + +{ ngx_string("orig_remote_addr"), NULL, + ngx_http_realip_orig_remote_addr_variable, 0, NGX_HTTP_VAR_NOHASH, 0 }, + +{ ngx_null_string, NULL, NULL, 0, 0, 0 } +}; + + static ngx_int_t ngx_http_realip_handler(ngx_http_request_t *r) { @@ -369,6 +382,55 @@ } +static ngx_int_t +ngx_http_realip_orig_remote_addr_variable(ngx_http_request_t *r, +ngx_http_variable_value_t *v, uintptr_t data) +{ +ngx_http_realip_ctx_t *ctx; + +ctx = ngx_http_get_module_ctx(r, ngx_http_realip_module); + +if (ctx == NULL) { +v->not_found = 1; +return NGX_OK; +} + +v->len = ctx->addr_text.len; +v->data = ngx_pnalloc(r->pool, v->len); + +if (v->data == NULL) { +return NGX_ERROR; +} + +ngx_memcpy(v->data, ctx->addr_text.data, v->len); + +v->valid = 1; +v->no_cacheable = 0; +v->not_found = 0; + +return NGX_OK; +} + + +static ngx_int_t +ngx_http_realip_add_variables(ngx_conf_t *cf) +{ +ngx_http_variable_t *var, *v; + +for (v = ngx_http_realip_vars; v->name.len; v++) { +var = ngx_http_add_variable(cf, &v->name, v->flags); +if (var == NULL) { +return NGX_ERROR; +} + +var->get_handler = v->get_handler; +var->data = v->data; +} + +return NGX_OK; +} + + static void * ngx_http_realip_create_loc_conf(ngx_conf_t *cf) { ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel
[nginx] Stream: fixed "reuseport" to actually work.
details: http://hg.nginx.org/nginx/rev/f654addf0eea branches: changeset: 6169:f654addf0eea user: Ruslan Ermilov date: Fri Jun 05 23:03:13 2015 +0300 description: Stream: fixed "reuseport" to actually work. diffstat: src/stream/ngx_stream.c | 7 +++ src/stream/ngx_stream.h | 3 +++ 2 files changed, 10 insertions(+), 0 deletions(-) diffs (37 lines): diff -r 62869a9b2e7d -r f654addf0eea src/stream/ngx_stream.c --- a/src/stream/ngx_stream.c Fri Jun 05 22:23:26 2015 +0300 +++ b/src/stream/ngx_stream.c Fri Jun 05 23:03:13 2015 +0300 @@ -314,6 +314,9 @@ found: #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) addr->ipv6only = listen->ipv6only; #endif +#if (NGX_HAVE_REUSEPORT) +addr->reuseport = listen->reuseport; +#endif return NGX_OK; } @@ -386,6 +389,10 @@ ngx_stream_optimize_servers(ngx_conf_t * ls->ipv6only = addr[i].ipv6only; #endif +#if (NGX_HAVE_REUSEPORT) +ls->reuseport = addr[i].reuseport; +#endif + stport = ngx_palloc(cf->pool, sizeof(ngx_stream_port_t)); if (stport == NULL) { return NGX_CONF_ERROR; diff -r 62869a9b2e7d -r f654addf0eea src/stream/ngx_stream.h --- a/src/stream/ngx_stream.h Fri Jun 05 22:23:26 2015 +0300 +++ b/src/stream/ngx_stream.h Fri Jun 05 23:03:13 2015 +0300 @@ -109,6 +109,9 @@ typedef struct { #if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) unsignedipv6only:1; #endif +#if (NGX_HAVE_REUSEPORT) +unsignedreuseport:1; +#endif unsignedso_keepalive:2; #if (NGX_HAVE_KEEPALIVE_TUNABLE) int tcp_keepidle; ___ nginx-devel mailing list nginx-devel@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx-devel