http3_push
http3_push_preload
- Two additional variables are available: $quic and $http3.
+ An additional variable is available: $quic.
The value of $quic is "quic" if QUIC connection is used,
- and empty string otherwise. The value of $http3 is a string
- "h3-xx" where "xx" is the supported draft number.
+ or an empty string otherwise.
Example configuration:
http {
log_format quic '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
- '"$http_referer" "$http_user_agent" "$quic" "$http3"';
+ '"$http_referer" "$http_user_agent" "$quic"';
access_log logs/access.log quic;
location / {
# required for browsers to direct them into quic port
- add_header Alt-Svc '$http3=":8443"; ma=86400';
+ add_header Alt-Svc 'h3=":8443"; ma=86400';
}
}
}
If you've got it right, in the access log you should see something like:
127.0.0.1 - - [24/Apr/2020:11:27:29 +0300] "GET / HTTP/3" 200 805 "-"
- "nghttp3/ngtcp2 client" "quic" "h3-29"
+ "nghttp3/ngtcp2 client" "quic"
5. Troubleshooting
#include <ngx_http.h>
-static ngx_int_t ngx_http_variable_http3(ngx_http_request_t *r,
- ngx_http_variable_value_t *v, uintptr_t data);
-static ngx_int_t ngx_http_v3_add_variables(ngx_conf_t *cf);
static void *ngx_http_v3_create_srv_conf(ngx_conf_t *cf);
static char *ngx_http_v3_merge_srv_conf(ngx_conf_t *cf, void *parent,
void *child);
static ngx_http_module_t ngx_http_v3_module_ctx = {
- ngx_http_v3_add_variables, /* preconfiguration */
+ NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
};
-static ngx_http_variable_t ngx_http_v3_vars[] = {
-
- { ngx_string("http3"), NULL, ngx_http_variable_http3, 0, 0, 0 },
-
- ngx_http_null_variable
-};
-
-
-static ngx_int_t
-ngx_http_variable_http3(ngx_http_request_t *r,
- ngx_http_variable_value_t *v, uintptr_t data)
-{
- v->valid = 1;
- v->no_cacheable = 1;
- v->not_found = 0;
-
- v->data = ngx_pnalloc(r->pool, sizeof("h3-xx") - 1);
- if (v->data == NULL) {
- return NGX_ERROR;
- }
-
- v->len = ngx_sprintf(v->data, "h3-%d", NGX_QUIC_DRAFT_VERSION) - v->data;
-
- return NGX_OK;
-}
-
-
-static ngx_int_t
-ngx_http_v3_add_variables(ngx_conf_t *cf)
-{
- ngx_http_variable_t *var, *v;
-
- for (v = ngx_http_v3_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_v3_create_srv_conf(ngx_conf_t *cf)
{