Welcome! Log In Create A New Profile

Advanced

Re: [nginx] support http2 per server

June 08, 2017 03:00AM
Sorry for the typo.

diff -r 5e05118678af src/http/modules/ngx_http_ssl_module.c
--- a/src/http/modules/ngx_http_ssl_module.c Mon May 29 23:33:38 2017 +0300
+++ b/src/http/modules/ngx_http_ssl_module.c Wed Jun 07 12:17:34 2017 -0400
@@ -234,6 +234,13 @@
offsetof(ngx_http_ssl_srv_conf_t, stapling_verify),
NULL },

+ { ngx_string("ssl_h2"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_SRV_CONF_OFFSET,
+ offsetof(ngx_http_ssl_srv_conf_t, h2),
+ NULL },
+
ngx_null_command
};

@@ -343,16 +350,17 @@
unsigned char *outlen, const unsigned char *in, unsigned int inlen,
void *arg)
{
- unsigned int srvlen;
- unsigned char *srv;
+ unsigned int srvlen;
+ unsigned char *srv;
#if (NGX_DEBUG)
- unsigned int i;
+ unsigned int i;
#endif
#if (NGX_HTTP_V2)
- ngx_http_connection_t *hc;
+ ngx_http_connection_t *hc;
+ ngx_http_ssl_srv_conf_t *sscf;
#endif
#if (NGX_HTTP_V2 || NGX_DEBUG)
- ngx_connection_t *c;
+ ngx_connection_t *c;

c = ngx_ssl_get_connection(ssl_conn);
#endif
@@ -367,8 +375,9 @@

#if (NGX_HTTP_V2)
hc = c->data;
+ sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module);

- if (hc->addr_conf->http2) {
+ if (hc->addr_conf->http2 && sscf->h2) {
srv =
(unsigned char *) NGX_HTTP_V2_ALPN_ADVERTISE
NGX_HTTP_NPN_ADVERTISE;
srvlen = sizeof(NGX_HTTP_V2_ALPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE)
- 1;
@@ -411,11 +420,13 @@

#if (NGX_HTTP_V2)
{
- ngx_http_connection_t *hc;
+ ngx_http_connection_t *hc;
+ ngx_http_ssl_srv_conf_t *sscf;

hc = c->data;
+ sscf = ngx_http_get_module_srv_conf(hc->conf_ctx, ngx_http_ssl_module);

- if (hc->addr_conf->http2) {
+ if (hc->addr_conf->http2 && sscf->h2) {
*out =
(unsigned char *) NGX_HTTP_V2_NPN_ADVERTISE
NGX_HTTP_NPN_ADVERTISE;
*outlen = sizeof(NGX_HTTP_V2_NPN_ADVERTISE NGX_HTTP_NPN_ADVERTISE)
- 1;
@@ -555,6 +566,7 @@
sscf->session_ticket_keys = NGX_CONF_UNSET_PTR;
sscf->stapling = NGX_CONF_UNSET;
sscf->stapling_verify = NGX_CONF_UNSET;
+ sscf->h2 = NGX_CONF_UNSET;

return sscf;
}
@@ -620,6 +632,8 @@
ngx_conf_merge_str_value(conf->stapling_responder,
prev->stapling_responder, "");

+ ngx_conf_merge_value(conf->h2, prev->h2, 0);
+
conf->ssl.log = cf->log;

if (conf->enable) {
diff -r 5e05118678af src/http/modules/ngx_http_ssl_module.h
--- a/src/http/modules/ngx_http_ssl_module.h Mon May 29 23:33:38 2017 +0300
+++ b/src/http/modules/ngx_http_ssl_module.h Wed Jun 07 12:17:34 2017 -0400
@@ -57,6 +57,8 @@

u_char *file;
ngx_uint_t line;
+
+ ngx_flag_t h2;
} ngx_http_ssl_srv_conf_t;


On Thu, Jun 8, 2017 at 12:07 PM, 洪志道 <hongzhidao@gmail.com> wrote:

> Hi!
> Now, http2 is enabled globally for 'listen' directive with ip:port.
> It seems it's possible to enable by server with sni, alpn, npn.
> Take a look, please.
>
> diff -r 5e05118678af src/http/modules/ngx_http_ssl_module.c
> --- a/src/http/modules/ngx_http_ssl_module.c Mon May 29 23:33:38 2017
> +0300
> +++ b/src/http/modules/ngx_http_ssl_module.c Wed Jun 07 12:17:34 2017
> -0400
> @@ -234,6 +234,13 @@
> offsetof(ngx_http_ssl_srv_conf_t, stapling_verify),
> NULL },
>
> + { ngx_string("ssl_h2"),
> + NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_FLAG,
> + ngx_http_ssl_enable,
> + NGX_HTTP_SRV_CONF_OFFSET,
> + offsetof(ngx_http_ssl_srv_conf_t, h2),
> + NULL },
> +
> ngx_null_command
> };
>
> @@ -343,16 +350,17 @@
> unsigned char *outlen, const unsigned char *in, unsigned int inlen,
> void *arg)
> {
> - unsigned int srvlen;
> - unsigned char *srv;
> + unsigned int srvlen;
> + unsigned char *srv;
> #if (NGX_DEBUG)
> - unsigned int i;
> + unsigned int i;
> #endif
> #if (NGX_HTTP_V2)
> - ngx_http_connection_t *hc;
> + ngx_http_connection_t *hc;
> + ngx_http_ssl_srv_conf_t *sscf;
> #endif
> #if (NGX_HTTP_V2 || NGX_DEBUG)
> - ngx_connection_t *c;
> + ngx_connection_t *c;
>
> c = ngx_ssl_get_connection(ssl_conn);
> #endif
> @@ -367,8 +375,9 @@
>
> #if (NGX_HTTP_V2)
> hc = c->data;
> + sscf = ngx_http_get_module_srv_conf(hc->conf_ctx,
> ngx_http_ssl_module);
>
> - if (hc->addr_conf->http2) {
> + if (hc->addr_conf->http2 && sscf->h2) {
> srv =
> (unsigned char *) NGX_HTTP_V2_ALPN_ADVERTISE
> NGX_HTTP_NPN_ADVERTISE;
> srvlen = sizeof(NGX_HTTP_V2_ALPN_ADVERTISE
> NGX_HTTP_NPN_ADVERTISE) - 1;
> @@ -411,11 +420,13 @@
>
> #if (NGX_HTTP_V2)
> {
> - ngx_http_connection_t *hc;
> + ngx_http_connection_t *hc;
> + ngx_http_ssl_srv_conf_t *sscf;
>
> hc = c->data;
> + sscf = ngx_http_get_module_srv_conf(hc->conf_ctx,
> ngx_http_ssl_module);
>
> - if (hc->addr_conf->http2) {
> + if (hc->addr_conf->http2 && sscf->h2) {
> *out =
> (unsigned char *) NGX_HTTP_V2_NPN_ADVERTISE
> NGX_HTTP_NPN_ADVERTISE;
> *outlen = sizeof(NGX_HTTP_V2_NPN_ADVERTISE
> NGX_HTTP_NPN_ADVERTISE) - 1;
> @@ -555,6 +566,7 @@
> sscf->session_ticket_keys = NGX_CONF_UNSET_PTR;
> sscf->stapling = NGX_CONF_UNSET;
> sscf->stapling_verify = NGX_CONF_UNSET;
> + sscf->h2 = NGX_CONF_UNSET;
>
> return sscf;
> }
> @@ -620,6 +632,8 @@
> ngx_conf_merge_str_value(conf->stapling_responder,
> prev->stapling_responder, "");
>
> + ngx_conf_merge_value(conf->h2, prev->h2, 0);
> +
> conf->ssl.log = cf->log;
>
> if (conf->enable) {
> diff -r 5e05118678af src/http/modules/ngx_http_ssl_module.h
> --- a/src/http/modules/ngx_http_ssl_module.h Mon May 29 23:33:38 2017
> +0300
> +++ b/src/http/modules/ngx_http_ssl_module.h Wed Jun 07 12:17:34 2017
> -0400
> @@ -57,6 +57,8 @@
>
> u_char *file;
> ngx_uint_t line;
> +
> + ngx_flag_t h2;
> } ngx_http_ssl_srv_conf_t;
>
> Thanks.
> B.R.
>
>
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] support http2 per server

karton 821 June 08, 2017 12:08AM

Re: [nginx] support http2 per server

karton 337 June 08, 2017 03:00AM

Re: [nginx] support http2 per server

Valentin V. Bartenev 299 June 08, 2017 10:18AM

Re: [nginx] support http2 per server

karton 326 June 08, 2017 11:20AM

Re: [nginx] support http2 per server

Valentin V. Bartenev 299 June 08, 2017 11:26AM

Re: [nginx] support http2 per server

karton 332 June 08, 2017 12:10PM

Re: [nginx] support http2 per server

Valentin V. Bartenev 316 June 08, 2017 01:10PM

Re: [nginx] support http2 per server

karton 375 June 08, 2017 01:18PM

Re: [nginx] support http2 per server

Neil Craig 306 June 08, 2017 01:22PM

Re: [nginx] support http2 per server

karton 392 June 09, 2017 01:42AM

Re: [nginx] support http2 per server

Valentin V. Bartenev 303 June 09, 2017 07:46AM

Re: [nginx] support http2 per server

karton 375 June 09, 2017 08:28AM

Re: [nginx] support http2 per server

karton 381 June 09, 2017 08:58AM

Re: [nginx] support http2 per server

InfoHunter 368 June 09, 2017 02:08PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 180
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready