diff --git a/auto/modules b/auto/modules index 04a7aca..67fe2cb 100644 --- a/auto/modules +++ b/auto/modules @@ -227,7 +227,6 @@ if [ $HTTP = YES ]; then . auto/module fi - if :; then ngx_module_name=ngx_http_range_header_filter_module ngx_module_incs= diff --git a/auto/options b/auto/options index ed55922..4abd20a 100644 --- a/auto/options +++ b/auto/options @@ -117,6 +117,7 @@ MAIL_SMTP=YES STREAM=NO STREAM_SSL=NO +STREAM_REALIP=NO STREAM_LIMIT_CONN=YES STREAM_ACCESS=YES STREAM_GEO=YES @@ -127,6 +128,7 @@ STREAM_RETURN=YES STREAM_UPSTREAM_HASH=YES STREAM_UPSTREAM_LEAST_CONN=YES STREAM_UPSTREAM_ZONE=YES +STREAM_SSL_PREREAD=NO DYNAMIC_MODULES= @@ -316,6 +318,7 @@ use the \"--with-mail_ssl_module\" option instead" --without-stream_limit_conn_module) STREAM_LIMIT_CONN=NO ;; --without-stream_access_module) STREAM_ACCESS=NO ;; + --without-stream_geo_module) STREAM_GEO=NO ;; --without-stream_map_module) STREAM_MAP=NO ;; --without-stream_split_clients_module) STREAM_SPLIT_CLIENTS=NO ;; @@ -526,6 +529,7 @@ cat << END --with-stream_ssl_preread_module enable ngx_stream_ssl_preread_module --without-stream_limit_conn_module disable ngx_stream_limit_conn_module --without-stream_access_module disable ngx_stream_access_module + --without-stream_geo_module disable ngx_stream_geo_module --without-stream_map_module disable ngx_stream_map_module --without-stream_split_clients_module disable ngx_stream_split_clients_module diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h index ae83d4b..e4dfe58 100644 --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -182,7 +182,7 @@ struct ngx_connection_s { unsigned need_last_buf:1; -#if (NGX_HAVE_AIO_SENDFILE || NGX_COMPAT) +#if (NGX_HAVE_AIO_SENDFILE || NGX_COMPAT) unsigned busy_count:2; #endif diff --git a/src/core/ngx_core.h b/src/core/ngx_core.h index 7a4afd0..2069373 100644 --- a/src/core/ngx_core.h +++ b/src/core/ngx_core.h @@ -12,19 +12,19 @@ #include -typedef struct ngx_module_s ngx_module_t; -typedef struct ngx_conf_s ngx_conf_t; -typedef struct ngx_cycle_s ngx_cycle_t; -typedef struct ngx_pool_s ngx_pool_t; -typedef struct ngx_chain_s ngx_chain_t; -typedef struct ngx_log_s ngx_log_t; -typedef struct ngx_open_file_s ngx_open_file_t; -typedef struct ngx_command_s ngx_command_t; -typedef struct ngx_file_s ngx_file_t; -typedef struct ngx_event_s ngx_event_t; -typedef struct ngx_event_aio_s ngx_event_aio_t; -typedef struct ngx_connection_s ngx_connection_t; -typedef struct ngx_thread_task_s ngx_thread_task_t; +typedef struct ngx_module_s ngx_module_t; +typedef struct ngx_conf_s ngx_conf_t; +typedef struct ngx_cycle_s ngx_cycle_t; +typedef struct ngx_pool_s ngx_pool_t; +typedef struct ngx_chain_s ngx_chain_t; +typedef struct ngx_log_s ngx_log_t; +typedef struct ngx_open_file_s ngx_open_file_t; +typedef struct ngx_command_s ngx_command_t; +typedef struct ngx_file_s ngx_file_t; +typedef struct ngx_event_s ngx_event_t; +typedef struct ngx_event_aio_s ngx_event_aio_t; +typedef struct ngx_connection_s ngx_connection_t; +typedef struct ngx_thread_task_s ngx_thread_task_t; typedef struct ngx_ssl_s ngx_ssl_t; typedef struct ngx_ssl_connection_s ngx_ssl_connection_t; diff --git a/src/event/ngx_event_openssl.h b/src/event/ngx_event_openssl.h index c3f5fc9..9996e47 100644 --- a/src/event/ngx_event_openssl.h +++ b/src/event/ngx_event_openssl.h @@ -55,6 +55,11 @@ #define ngx_ssl_conn_t SSL +#if (OPENSSL_VERSION_NUMBER < 0x10002000L) +#define SSL_is_server(s) (s)->server +#endif + + typedef struct { ngx_msec_t timeout; ngx_uint_t threshold; @@ -63,11 +68,6 @@ typedef struct { } ngx_ssl_dyn_rec_t; -#if (OPENSSL_VERSION_NUMBER < 0x10002000L) -#define SSL_is_server(s) (s)->server -#endif - - struct ngx_ssl_s { SSL_CTX *ctx; ngx_log_t *log; diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index d5668ec..87eaa56 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -3783,7 +3783,7 @@ ngx_http_core_listen(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) lsopt.fastopen = -1; #endif lsopt.wildcard = u.wildcard; -#if (NGX_HAVE_INET6 && defined IPV6_V6ONLY) +#if (NGX_HAVE_INET6) lsopt.ipv6only = 1; #endif diff --git a/src/http/ngx_http_header_filter_module.c b/src/http/ngx_http_header_filter_module.c index 7cd9f38..49277a1 100644 --- a/src/http/ngx_http_header_filter_module.c +++ b/src/http/ngx_http_header_filter_module.c @@ -226,7 +226,6 @@ ngx_http_header_filter(ngx_http_request_t *r) r->headers_out.last_modified = NULL; r->headers_out.content_length = NULL; r->headers_out.content_length_n = -1; - r->keepalive = 0; } status -= NGX_HTTP_OK; @@ -280,7 +279,7 @@ ngx_http_header_filter(ngx_http_request_t *r) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (r->headers_out.server == NULL && r->headers_out.status != NGX_HTTP_NO_CONTENT) { + if (r->headers_out.server == NULL) { if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) { len += sizeof(ngx_http_server_full_string) - 1; @@ -449,7 +448,7 @@ ngx_http_header_filter(ngx_http_request_t *r) } *b->last++ = CR; *b->last++ = LF; - if (r->headers_out.server == NULL && r->headers_out.status != NGX_HTTP_NO_CONTENT) { + if (r->headers_out.server == NULL) { if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) { p = ngx_http_server_full_string; len = sizeof(ngx_http_server_full_string) - 1; diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index b292729..539578d 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -833,7 +833,7 @@ ngx_http_ssl_handshake_handler(ngx_connection_t *c) ngx_http_close_connection(c); } -#ifdef SSL_set_tlsext_host_name +#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME int ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg) @@ -912,7 +912,7 @@ ngx_http_ssl_servername(ngx_ssl_conn_t *ssl_conn, int *ad, void *arg) SSL_set_verify_depth(ssl_conn, SSL_CTX_get_verify_depth(sscf->ssl.ctx)); -#ifdef SSL_CTX_clear_options +#ifdef SSL_CTRL_CLEAR_OPTIONS /* only in 0.9.8m+ */ SSL_clear_options(ssl_conn, SSL_get_options(ssl_conn) & ~SSL_CTX_get_options(sscf->ssl.ctx)); @@ -2051,7 +2051,7 @@ ngx_http_set_virtual_server(ngx_http_request_t *r, ngx_str_t *host) hc = r->http_connection; -#if (NGX_HTTP_SSL && defined SSL_set_tlsext_host_name) +#if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME) if (hc->ssl_servername) { if (hc->ssl_servername->len == host->len @@ -2082,7 +2082,7 @@ ngx_http_set_virtual_server(ngx_http_request_t *r, ngx_str_t *host) return NGX_ERROR; } -#if (NGX_HTTP_SSL && defined SSL_set_tlsext_host_name) +#if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME) if (hc->ssl_servername) { ngx_http_ssl_srv_conf_t *sscf; @@ -2149,7 +2149,7 @@ ngx_http_find_virtual_server(ngx_connection_t *c, sn = virtual_names->regex; -#if (NGX_HTTP_SSL && defined SSL_set_tlsext_host_name) +#if (NGX_HTTP_SSL && defined SSL_CTRL_SET_TLSEXT_HOSTNAME) if (r == NULL) { ngx_http_connection_t *hc; diff --git a/src/http/v2/ngx_http_v2.h b/src/http/v2/ngx_http_v2.h index cee6acb..ae826af 100644 --- a/src/http/v2/ngx_http_v2.h +++ b/src/http/v2/ngx_http_v2.h @@ -12,6 +12,7 @@ #include #include + #define NGX_HTTP_V2_ALPN_ADVERTISE "\x02h2" #define NGX_HTTP_V2_NPN_ADVERTISE NGX_HTTP_V2_ALPN_ADVERTISE @@ -59,12 +60,13 @@ #define NGX_HTTP_V2_DEFAULT_HPACK_TABLE_SIZE 4096 #define NGX_HTTP_V2_MAX_HPACK_TABLE_SIZE 16384 /* < 64k */ +#define NGX_HTTP_V2_DEFAULT_WEIGHT 16 + + typedef struct ngx_http_v2_connection_s ngx_http_v2_connection_t; typedef struct ngx_http_v2_node_s ngx_http_v2_node_t; typedef struct ngx_http_v2_out_frame_s ngx_http_v2_out_frame_t; -#define NGX_HTTP_V2_DEFAULT_WEIGHT 16 - typedef u_char *(*ngx_http_v2_handler_pt) (ngx_http_v2_connection_t *h2c, u_char *pos, u_char *end); @@ -251,6 +253,8 @@ struct ngx_http_v2_stream_s { ngx_array_t *cookies; + size_t header_limit; + ngx_pool_t *pool; unsigned waiting:1; @@ -462,11 +466,14 @@ size_t ngx_http_v2_huff_encode(u_char *src, size_t len, u_char *dst, u_char *ngx_http_v2_string_encode(u_char *dst, u_char *src, size_t len, u_char *tmp, ngx_uint_t lower); - -/* Not default source */ u_char * ngx_http_v2_write_int(u_char *pos, ngx_uint_t prefix, ngx_uint_t value); +#define ngx_http_v2_write_name(dst, src, len, tmp) \ + ngx_http_v2_string_encode(dst, src, len, tmp, 1) +#define ngx_http_v2_write_value(dst, src, len, tmp) \ + ngx_http_v2_string_encode(dst, src, len, tmp, 0) + u_char * ngx_http_v2_write_header(ngx_http_v2_connection_t *h2c, u_char *pos, u_char *key, size_t key_len, u_char *value, size_t value_len, @@ -483,5 +490,4 @@ ngx_http_v2_table_resize(ngx_http_v2_connection_t *h2c); ngx_http_v2_write_header(h2c, pos, (u_char *) key, sizeof(key) - 1, \ val.data, val.len, tmp); - #endif /* _NGX_HTTP_V2_H_INCLUDED_ */ diff --git a/src/http/v2/ngx_http_v2_encode.c b/src/http/v2/ngx_http_v2_encode.c index da6b515..d1fb721 100644 --- a/src/http/v2/ngx_http_v2_encode.c +++ b/src/http/v2/ngx_http_v2_encode.c @@ -10,6 +10,10 @@ #include +u_char *ngx_http_v2_write_int(u_char *pos, ngx_uint_t prefix, + ngx_uint_t value); + + u_char * ngx_http_v2_string_encode(u_char *dst, u_char *src, size_t len, u_char *tmp, ngx_uint_t lower) diff --git a/src/http/v2/ngx_http_v2_filter_module.c b/src/http/v2/ngx_http_v2_filter_module.c index 6a09a41..212d6fc 100644 --- a/src/http/v2/ngx_http_v2_filter_module.c +++ b/src/http/v2/ngx_http_v2_filter_module.c @@ -23,6 +23,38 @@ #define ngx_http_v2_literal_size(h) \ (ngx_http_v2_integer_octets(sizeof(h) - 1) + sizeof(h) - 1) +#define ngx_http_v2_indexed(i) (128 + (i)) +#define ngx_http_v2_inc_indexed(i) (64 + (i)) + +#define NGX_HTTP_V2_ENCODE_RAW 0 +#define NGX_HTTP_V2_ENCODE_HUFF 0x80 + +#define NGX_HTTP_V2_AUTHORITY_INDEX 1 +#define NGX_HTTP_V2_METHOD_GET_INDEX 2 +#define NGX_HTTP_V2_PATH_INDEX 4 + +#define NGX_HTTP_V2_SCHEME_HTTP_INDEX 6 +#define NGX_HTTP_V2_SCHEME_HTTPS_INDEX 7 + +#define NGX_HTTP_V2_STATUS_INDEX 8 +#define NGX_HTTP_V2_STATUS_200_INDEX 8 +#define NGX_HTTP_V2_STATUS_204_INDEX 9 +#define NGX_HTTP_V2_STATUS_206_INDEX 10 +#define NGX_HTTP_V2_STATUS_304_INDEX 11 +#define NGX_HTTP_V2_STATUS_400_INDEX 12 +#define NGX_HTTP_V2_STATUS_404_INDEX 13 +#define NGX_HTTP_V2_STATUS_500_INDEX 14 + +#define NGX_HTTP_V2_ACCEPT_ENCODING_INDEX 16 +#define NGX_HTTP_V2_ACCEPT_LANGUAGE_INDEX 17 +#define NGX_HTTP_V2_CONTENT_LENGTH_INDEX 28 +#define NGX_HTTP_V2_CONTENT_TYPE_INDEX 31 +#define NGX_HTTP_V2_DATE_INDEX 33 +#define NGX_HTTP_V2_LAST_MODIFIED_INDEX 44 +#define NGX_HTTP_V2_LOCATION_INDEX 46 +#define NGX_HTTP_V2_SERVER_INDEX 54 +#define NGX_HTTP_V2_USER_AGENT_INDEX 58 +#define NGX_HTTP_V2_VARY_INDEX 59 #define NGX_HTTP_V2_NO_TRAILERS (ngx_http_v2_out_frame_t *) -1 @@ -148,17 +180,11 @@ ngx_http_v2_header_filter(ngx_http_request_t *r) ngx_http_core_srv_conf_t *cscf; u_char addr[NGX_SOCKADDR_STRLEN]; - //static const u_char nginx[5] = "\x84\xaa\x63\x55\xe7"; #if (NGX_HTTP_GZIP) static const u_char accept_encoding[12] = "\x8b\x84\x84\x2d\x69\x5b\x05\x44\x3c\x86\xaa\x6f"; #endif - static size_t nginx_ver_len = ngx_http_v2_literal_size(NGINX_SERVER_FULL); - - static size_t nginx_ver_build_len = - ngx_http_v2_literal_size(NGINX_SERVER_FULL_BUILD); - stream = r->stream; if (!stream) { @@ -257,16 +283,15 @@ ngx_http_v2_header_filter(ngx_http_request_t *r) clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (r->headers_out.server == NULL && r->headers_out.status != NGX_HTTP_NO_CONTENT) { + if (r->headers_out.server == NULL) { if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) { - len += 1 + nginx_ver_len; + len += 1 + ngx_http_v2_literal_size(NGINX_SERVER_FULL); } else if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_BUILD) { - len += 1 + nginx_ver_build_len; + len += 1 + ngx_http_v2_literal_size(NGINX_SERVER_FULL_BUILD); } else { - //len += 1 + sizeof(NGINX_SERVER); len += 1 + ngx_http_v2_literal_size(NGINX_SERVER); } } @@ -467,7 +492,7 @@ ngx_http_v2_header_filter(ngx_http_request_t *r) sizeof(":status") - 1, pos + 8, 3, tmp); } - if (r->headers_out.server == NULL && r->headers_out.status != NGX_HTTP_NO_CONTENT) { + if (r->headers_out.server == NULL) { if (clcf->server_tokens == NGX_HTTP_SERVER_TOKENS_ON) { pos = ngx_http_v2_write_header_str("server", NGINX_SERVER_FULL); @@ -485,8 +510,6 @@ ngx_http_v2_header_filter(ngx_http_request_t *r) } if (r->headers_out.content_type.len) { - //*pos++ = ngx_http_v2_inc_indexed(NGX_HTTP_V2_CONTENT_TYPE_INDEX); - if (r->headers_out.content_type_len == r->headers_out.content_type.len && r->headers_out.charset.len) { @@ -609,7 +632,7 @@ ngx_http_v2_push_resources(ngx_http_request_t *r) ngx_http_complex_value_t *pushes; ngx_str_t binary[NGX_HTTP_V2_PUSH_HEADERS]; - ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http2 push resources"); ngx_memzero(binary, NGX_HTTP_V2_PUSH_HEADERS * sizeof(ngx_str_t)); @@ -620,6 +643,7 @@ ngx_http_v2_push_resources(ngx_http_request_t *r) pushes = h2lcf->pushes->elts; for (i = 0; i < h2lcf->pushes->nelts; i++) { + if (ngx_http_complex_value(r, &pushes[i], &path) != NGX_OK) { return NGX_ERROR; } diff --git a/src/os/win32/ngx_process.h b/src/os/win32/ngx_process.h index 36a86ac..7ec4cd9 100644 --- a/src/os/win32/ngx_process.h +++ b/src/os/win32/ngx_process.h @@ -17,6 +17,7 @@ typedef DWORD ngx_pid_t; #define ngx_getppid() 0 #define ngx_log_pid ngx_pid + #define NGX_PROCESS_SYNC_NAME \ (sizeof("ngx_cache_manager_mutex_") + NGX_INT32_LEN)