icing / mod_h2

HTTP/2 module for Apache httpd
https://icing.github.io/mod_h2/
Apache License 2.0
256 stars 41 forks source link

mod_http2 : Warn user if nghttp2 not available on apache2 start #156

Closed teolaz closed 6 years ago

teolaz commented 6 years ago

Is it possible to have a message when nghttp2 isn't installed or is installed in a different directory from apache2 known nghttp2 dir? You could save tons of time for non-expert users... I don't believe enabling mod_http2 has sense unless you don't have nghttp2 enabled and mod_http2 configured to read the correct directory...

icing commented 6 years ago

If I understand you correctly, the root cause for such a problem, would be that somehow mod_http2 was installed, but the package for nghttp2 was not. If you installed this via a package manager, someone seems to have fumbled the dependencies. Then that needs fixing.

As to a2enmod: that just changes a symbolic link in the file system. It does not know what dependencies might be encountered when loading a module. And it should not guess theses things. The server knows.

So, could you not check that this works with the apache2ctl -t command?

teolaz commented 6 years ago

As on Ubuntu16.04, you cannot install Apache2 using apt with mod_http2 support unless you add the Ondrej repo... Then, yes, i think the nghttp2 wasn't set up correctly as dependency on apt...

I installed Apache and enabled mod_http2 (ssl was already) using Ondrej repo and naturally i put Protocols h2 hc2 http/1.1 directive on my vhost:

root@linode-prod:/usr/share/nghttp2# apache2ctl -v
Server version: Apache/2.4.29 (Ubuntu)
Server built:   2018-01-14T11:23:59
root@linode-prod:/usr/share/nghttp2# apache2ctl -M
Loaded Modules:
 core_module (static)
 so_module (static)
 watchdog_module (static)
 http_module (static)
 log_config_module (static)
 logio_module (static)
 version_module (static)
 unixd_module (static)
 access_compat_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_core_module (shared)
 authn_file_module (shared)
 authz_core_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 deflate_module (shared)
 dir_module (shared)
 env_module (shared)
 filter_module (shared)
 headers_module (shared)
 http2_module (shared)
 mime_module (shared)
 mpm_prefork_module (shared)
 negotiation_module (shared)
 php7_module (shared)
 reqtimeout_module (shared)
 rewrite_module (shared)
 setenvif_module (shared)
 socache_shmcb_module (shared)
 ssl_module (shared)
 status_module (shared)
 unique_id_module (shared)

and nghttp apart (as this wasnt' a dependency):

root@linode-prod:/usr/share/nghttp2# nghttp --version
nghttp nghttp2/1.29.0

but i still cannot see http2 responses... I believe i should recompile apache2 from sources to give him the exact nghttp2 path, but i personally don't like the approach in this case...

I'm wondering if any system put the executable and libs in different paths(??).. There's neither a error.log row which tries to say mod_http2 cannot find local nghttp...

teolaz commented 6 years ago

And yes...

As to a2enmod: that just changes a symbolic link in the file system. It does not know what dependencies might be encountered when loading a module. And it should not guess theses things. The server knows.

I believe the server knows exactly which files need to work... So why when you start apache without dependencies wouldn't throw an error on error.log?

icing commented 6 years ago

If the module was loaded, I'd assume that it could resolve all links. I think the problem is somewhere else.

icing commented 6 years ago

Yes, if link dependencies cannot be resolved on module loading, your server will not start.

teolaz commented 6 years ago

Yes, if link dependencies cannot be resolved on module loading, your server will not start.

So, are you saying mod_http2 already check if nghttp2 libraries are installed and won't start apache2 server without them?

In this case, the problem isn't nghttp2 not found as dependency, but i still argue to find a reason why the system isn't answering with http2 headers...

teolaz commented 6 years ago

Ok, i think i found the problem....

[Mon Feb 19 12:44:59.790352 2018] [http2:info] [pid 5171] AH03090: mod_http2 (v1.10.12, feats=CHPRIO+SHA256+INVHD+DWINS, nghttp2 1.29.0), initializing...
[Mon Feb 19 12:44:59.790410 2018] [http2:warn] [pid 5171] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
icing commented 6 years ago

Ah, the classic. Note that some package updates seem to trigger a fallback to mpm_prefork for some reason. I noticed that on a Ubuntu server of mine.