Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#800 closed defect (fixed)

Variable $server_protocol is empty on HTTP2

Reported by: uu@… Owned by: Valentin V. Bartenev
Priority: major Milestone:
Component: nginx-core Version: 1.9.x
Keywords: http2 server_protocol Cc:
uname -a: Linux testmachine 4.1.1-gentoo-r1 #1 SMP Tue Jul 7 13:11:58 MSK 2015 x86_64 Intel(R) Core(TM) i7 CPU 950 @ 3.07GHz GenuineIntel GNU/Linux
nginx -V: nginx version: nginx/1.9.5
built with OpenSSL 1.0.2d 9 Jul 2015
TLS SNI support enabled
configure arguments: --prefix=/usr --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error_log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-cc-opt=-I/usr/include --with-ld-opt=-L/usr/lib --http-log-path=/var/log/nginx/access_log --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-scgi-temp-path=/var/tmp/nginx/scgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --with-pcre --with-pcre-jit --with-http_v2_module --without-http_limit_conn_module --without-http_scgi_module --without-http_upstream_ip_hash_module --without-http_uwsgi_module --add-module=/var/tmp/portage/www-servers/nginx-1.9.5-r1/work/bodytime-nginx-module-8b47f5c049b8afd5b0d639f747e47446597c22e4 --with-http_addition_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_stub_status_module --with-http_sub_module --with-http_xslt_module --with-http_realip_module --add-module=/var/tmp/portage/www-servers/nginx-1.9.5-r1/work/simpl-ngx_devel_kit-8dd0df5 --add-module=/var/tmp/portage/www-servers/nginx-1.9.5-r1/work/ngx_http_pinba_module-master --add-module=/var/tmp/portage/www-servers/nginx-1.9.5-r1/work/lua-nginx-module-0.9.16 --add-module=/var/tmp/portage/www-servers/nginx-1.9.5-r1/work/openresty-headers-more-nginx-module-ccaede8 --with-http_ssl_module --add-module=/var/tmp/portage/www-servers/nginx-1.9.5-r1/work/ngx_http_auth_pam_module-1.4 --without-mail_imap_module --without-mail_pop3_module --without-mail_smtp_module --user=nginx --group=nginx

Description

That's it:)

Change History (6)

comment:1 by maxim, 9 years ago

Owner: set to Valentin V. Bartenev
Status: newassigned

comment:2 by Valentin V. Bartenev, 9 years ago

Resolution: fixed
Status: assignedclosed

Fixed by 9dfc4ba140f9 (will be released in 1.9.6).

comment:3 by John Blackbourn, 9 years ago

Resolution: fixed
Status: closedreopened

Although it's not actually clear from the HTTP/2 spec, shouldn't this be HTTP/2, not HTTP/2.0?

Ref: Is it HTTP/2.0 or HTTP/2?

comment:4 by Ilyas Bakirov, 9 years ago

As far as I know protocol name is HTTP/2 but protocol number is HTTP/2.0

Almost I used servers like Jetty and Apache2 use HTTP/2.0 as http version

Version 0, edited 9 years ago by Ilyas Bakirov (next)

comment:5 by Valentin V. Bartenev, 9 years ago

Resolution: fixed
Status: reopenedclosed

According to RFC7230 HTTP/2 isn't a valid HTTP-Version token, and since the variable is mostly used in access-logs it should be compatible to what most log parsers expect here.

Last edited 9 years ago by Valentin V. Bartenev (previous) (diff)

in reply to:  5 comment:6 by Rob Janssen, 9 years ago

Replying to vbart:

and since the variable is mostly used in access-logs

Hmmm, I wouldn't be so sure...

I came across at least 3 instances where this would cause trouble or at least minor inconveniences:

SpotWeb:
https://github.com/spotweb/spotweb/blob/master/settings.php#L31
https://github.com/spotweb/spotweb/blob/master/lib/SpotCommandline.php#L21

OwnCloud:
https://github.com/owncloud/core/blob/master/lib/private/response.php#L77
https://github.com/owncloud/core/blob/master/lib/private/appframework/dependencyinjection/dicontainer.php#L255

PHP documentation: (granted, 6yr old comment)
http://php.net/manual/en/function.header.php#92305

I used the following construction on several occasions (PHP, not saying this is "good code"):

header(sprintf("%s 404 Not Found", isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0'));

For now, I 'solved' it by changing /etc/nginx/factcgi_params:

#fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  SERVER_PROTOCOL    HTTP/2.0;

The release of 1.9.6 would be very welcome to me ;-)

Last edited 9 years ago by Rob Janssen (previous) (diff)
Note: See TracTickets for help on using tickets.