HTTP/2 und TLSv1.3

Ich verzweifle echt an zwei Punkten und wollte um eure Hilfe bitten.

Meine Versionen:

OpenSSL 1.1.1i 8 Dec 2020
Server version: Apache/2.4.38 (Debian)
Server built: 2020-08-25T20:08:29
Nextcloud: 21.0.0

Screenshot_20210223_162800_com.server.auditor.ssh.client

Trotz Einstellung des Protocol: TLSv1.3 wird beim Prüfen der Seite alles deaktiviert angezeigt bis auf TLSv1.2

Hoffe es kann mir wer helfen und auch beim Punkt wie ich HTTP/2 aktiviere.

Ich danke euch jz schon.

TLS v1.3:

HTTP/2:

Um HTTP/2 zu aktivieren kannst dir auch eine seperate http2.conf Datei anlegen. Dann ist HTTP/2 gleich für alle Virtualhosts aktiv, falls du mehrere nutzt.

sudo a2enmod http2 && sudo systemctl restart apache2

sudo nano /etc/apache2/conf-available/http2.conf

und folgendes in die leere Datei einfügen:

<IfModule http2_module>
Protocols h2 h2c http/1.1
H2Direct on
H2StreamMaxMemSize 5120000000
</IfModule>

Die Datei speichern und schliessen und dann folgendes ausführen:

sudo a2enconf http2 && sudo systemctl restart apache2

Betreffend SSL nutze ich folgende Konfiguration:

SSLProtocol -all +TLSv1.3 +TLSv1.2

Damit ist nur noch TLSv1.2 und TLSv1.3 aktiv. Wenn du keine uralten Browser und/oder Clients mehr nutzt, sollte das genügen.

TLSv1.3 sollte aber eigentlich mittlerweile jeder aktuelle Let’s Encrypt Client automatisch machen. Evtl. müsstest du hier mal deine komplette Apache Config posten, und etwas mehr Infos wie du alles eingerichtet hast, falls es mit den Anleitungen von @j-ed und meinem Hinweis nicht klappt.

Super :slight_smile:
TLSv1.3 funktioniert jz, danke euch nur mit http/2 komme ich nicht weiter obwohl aktiv. Wenn noch was benötigt wird bitte sagen. Danke für die tolle Unterstützung.

<IfModule http2_module>
Protocols h2 h2c http/1.1
H2Direct on
H2StreamMaxMemSize 5120000000
</IfModule>

# HTTP2 configuration
H2Push          on
H2PushPriority  *                       after
H2PushPriority  text/css                before
H2PushPriority  image/jpeg              after   32
H2PushPriority  image/png               after   32
H2PushPriority  application/javascript  interleaved

# SSL/TLS Configuration
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLHonorCipherOrder on
SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
SSLCompression          off
SSLSessionTickets       on

# OCSP Stapling
SSLUseStapling          on
SSLStaplingResponderTimeout 5
SSLStaplingReturnResponderErrors off
SSLStaplingCache        shmcb:/var/run/ocsp(128000)

TLSv1.3 Ergebnis

Screenshot_20210223_201806_com.chrome.beta

Weiteres wegen HTTP/2, dennoch klappt es nicht, übersehe ich in der oberen Einstellung etwas sowie in dieser?

<IfModule mod_ssl.c>
	<VirtualHost _default_:443>
                Protocols h2 h2c http/1.1
		ServerAdmin webmaster@localhost
		DocumentRoot /var/www/html

		# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
		# error, crit, alert, emerg.
		# It is also possible to configure the loglevel for particular
		# modules, e.g.
		#LogLevel info ssl:warn

		ErrorLog ${APACHE_LOG_DIR}/error.log
		CustomLog ${APACHE_LOG_DIR}/access.log combined

		# For most configuration files from conf-available/, which are
		# enabled or disabled at a global level, it is possible to
		# include a line for only one particular virtual host. For example the
		# following line enables the CGI configuration for this host only
		# after it has been globally disabled with "a2disconf".
		#Include conf-available/serve-cgi-bin.conf

		#   SSL Engine Switch:
		#   Enable/Disable SSL for this virtual host.
		SSLEngine on
                SSLProtocol all -SSLv2 -SSLv3
                
		#   A self-signed (snakeoil) certificate can be created by installing
		#   the ssl-cert package. See
		#   /usr/share/doc/apache2/README.Debian.gz for more info.
		#   If both key and certificate are stored in the same file, only the
		#   SSLCertificateFile directive is needed.
		SSLCertificateFile	/etc/ssl/certs/ssl-cert-snakeoil.pem
		SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

		#   Server Certificate Chain:
		#   Point SSLCertificateChainFile at a file containing the
		#   concatenation of PEM encoded CA certificates which form the
		#   certificate chain for the server certificate. Alternatively
		#   the referenced file can be the same as SSLCertificateFile
		#   when the CA certificates are directly appended to the server
		#   certificate for convinience.
		#SSLCertificateChainFile /etc/apache2/ssl.crt/server-ca.crt

		#   Certificate Authority (CA):
		#   Set the CA certificate verification path where to find CA
		#   certificates for client authentication or alternatively one
		#   huge file containing all of them (file must be PEM encoded)
		#   Note: Inside SSLCACertificatePath you need hash symlinks
		#		 to point to the certificate files. Use the provided
		#		 Makefile to update the hash symlinks after changes.
		#SSLCACertificatePath /etc/ssl/certs/
		#SSLCACertificateFile /etc/apache2/ssl.crt/ca-bundle.crt

		#   Certificate Revocation Lists (CRL):
		#   Set the CA revocation path where to find CA CRLs for client
		#   authentication or alternatively one huge file containing all
		#   of them (file must be PEM encoded)
		#   Note: Inside SSLCARevocationPath you need hash symlinks
		#		 to point to the certificate files. Use the provided
		#		 Makefile to update the hash symlinks after changes.
		#SSLCARevocationPath /etc/apache2/ssl.crl/
		#SSLCARevocationFile /etc/apache2/ssl.crl/ca-bundle.crl

		#   Client Authentication (Type):
		#   Client certificate verification type and depth.  Types are
		#   none, optional, require and optional_no_ca.  Depth is a
		#   number which specifies how deeply to verify the certificate
		#   issuer chain before deciding the certificate is not valid.
		#SSLVerifyClient require
		#SSLVerifyDepth  10

		#   SSL Engine Options:
		#   Set various options for the SSL engine.
		#   o FakeBasicAuth:
		#	 Translate the client X.509 into a Basic Authorisation.  This means that
		#	 the standard Auth/DBMAuth methods can be used for access control.  The
		#	 user name is the `one line' version of the client's X.509 certificate.
		#	 Note that no password is obtained from the user. Every entry in the user
		#	 file needs this password: `xxj31ZMTZzkVA'.
		#   o ExportCertData:
		#	 This exports two additional environment variables: SSL_CLIENT_CERT and
		#	 SSL_SERVER_CERT. These contain the PEM-encoded certificates of the
		#	 server (always existing) and the client (only existing when client
		#	 authentication is used). This can be used to import the certificates
		#	 into CGI scripts.
		#   o StdEnvVars:
		#	 This exports the standard SSL/TLS related `SSL_*' environment variables.
		#	 Per default this exportation is switched off for performance reasons,
		#	 because the extraction step is an expensive operation and is usually
		#	 useless for serving static content. So one usually enables the
		#	 exportation for CGI and SSI requests only.
		#   o OptRenegotiate:
		#	 This enables optimized SSL connection renegotiation handling when SSL
		#	 directives are used in per-directory context.
		#SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
		<FilesMatch "\.(cgi|shtml|phtml|php)$">
				SSLOptions +StdEnvVars
		</FilesMatch>
		<Directory /usr/lib/cgi-bin>
				SSLOptions +StdEnvVars
		</Directory>

		#   SSL Protocol Adjustments:
		#   The safe and default but still SSL/TLS standard compliant shutdown
		#   approach is that mod_ssl sends the close notify alert but doesn't wait for
		#   the close notify alert from client. When you need a different shutdown
		#   approach you can use one of the following variables:
		#   o ssl-unclean-shutdown:
		#	 This forces an unclean shutdown when the connection is closed, i.e. no
		#	 SSL close notify alert is send or allowed to received.  This violates
		#	 the SSL/TLS standard but is needed for some brain-dead browsers. Use
		#	 this when you receive I/O errors because of the standard approach where
		#	 mod_ssl sends the close notify alert.
		#   o ssl-accurate-shutdown:
		#	 This forces an accurate shutdown when the connection is closed, i.e. a
		#	 SSL close notify alert is send and mod_ssl waits for the close notify
		#	 alert of the client. This is 100% SSL/TLS standard compliant, but in
		#	 practice often causes hanging connections with brain-dead browsers. Use
		#	 this only for browsers where you know that their SSL implementation
		#	 works correctly.
		#   Notice: Most problems of broken clients are also related to the HTTP
		#   keep-alive facility, so you usually additionally want to disable
		#   keep-alive for those clients, too. Use variable "nokeepalive" for this.
		#   Similarly, one has to force some clients to use HTTP/1.0 to workaround
		#   their broken HTTP/1.1 implementation. Use variables "downgrade-1.0" and
		#   "force-response-1.0" for this.
		# BrowserMatch "MSIE [2-6]" \
		#		nokeepalive ssl-unclean-shutdown \
		#		downgrade-1.0 force-response-1.0

	</VirtualHost>
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Und die Apache2 conf:

# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.4/ for detailed information about
# the directives and /usr/share/doc/apache2/README.Debian about Debian specific
# hints.
#
#
# Summary of how the Apache 2 configuration works in Debian:
# The Apache 2 web server configuration in Debian is quite different to
# upstream's suggested way to configure the web server. This is because Debian's
# default Apache2 installation attempts to make adding and removing modules,
# virtual hosts, and extra configuration directives as flexible as possible, in
# order to make automating the changes and administering the server as easy as
# possible.

# It is split into several files forming the configuration hierarchy outlined
# below, all located in the /etc/apache2/ directory:
#
#	/etc/apache2/
#	|-- apache2.conf
#	|	`--  ports.conf
#	|-- mods-enabled
#	|	|-- *.load
#	|	`-- *.conf
#	|-- conf-enabled
#	|	`-- *.conf
# 	`-- sites-enabled
#	 	`-- *.conf
#
#
# * apache2.conf is the main configuration file (this file). It puts the pieces
#   together by including all remaining configuration files when starting up the
#   web server.
#
# * ports.conf is always included from the main configuration file. It is
#   supposed to determine listening ports for incoming connections which can be
#   customized anytime.
#
# * Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/
#   directories contain particular configuration snippets which manage modules,
#   global configuration fragments, or virtual host configurations,
#   respectively.
#
#   They are activated by symlinking available configuration files from their
#   respective *-available/ counterparts. These should be managed by using our
#   helpers a2enmod/a2dismod, a2ensite/a2dissite and a2enconf/a2disconf. See
#   their respective man pages for detailed information.
#
# * The binary is called apache2. Due to the use of environment variables, in
#   the default configuration, apache2 needs to be started/stopped with
#   /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not
#   work with the default configuration.


# Global configuration
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the Mutex documentation (available
# at <URL:http://httpd.apache.org/docs/2.4/mod/core.html#mutex>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
#ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#Mutex file:${APACHE_LOCK_DIR} default

#
# The directory where shm and other runtime files will be stored.
#

DefaultRuntimeDir ${APACHE_RUN_DIR}

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 5


# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog ${APACHE_LOG_DIR}/error.log

#
# LogLevel: Control the severity of messages logged to the error_log.
# Available values: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the log level for particular modules, e.g.
# "LogLevel info ssl:warn"
#
LogLevel warn

# Include module configuration:
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

# Include list of ports to listen on
Include ports.conf


# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
	Options FollowSymLinks
	AllowOverride None
	Require all denied
</Directory>

<Directory /usr/share>
	AllowOverride None
	Require all granted
</Directory>

<Directory /var/www/>
	Options Indexes FollowSymLinks
	AllowOverride All
	Require all granted
</Directory>

#<Directory /srv/>
#	Options Indexes FollowSymLinks
#	AllowOverride None
#	Require all granted
#</Directory>




# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#
AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
	Require all denied
</FilesMatch>


#
# The following directives define some format nicknames for use with
# a CustomLog directive.
#
# These deviate from the Common Log Format definitions in that they use %O
# (the actual bytes sent including headers) instead of %b (the size of the
# requested file), because the latter makes it impossible to detect partial
# requests.
#
# Note that the use of %{X-Forwarded-For}i instead of %h is not recommended.
# Use mod_remoteip instead.
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
IncludeOptional conf-enabled/*.conf

# Include the virtual host configurations:
IncludeOptional sites-enabled/*.conf

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
ServerName localhost
<IfModule mod_security2.c>
  SecServerSignature " "
</IfModule>

Mir ist nicht wirklich klar in welchen Dateien/Kontexten die verschiedenen Ausschnitte stehen. Und ist das HTTP2-Modul im Apache aktiviert?

Testen ob HTTP/2 aktiv ist auf einer Seite, in diesem Fall deiner Nextcloud, kannst du direkt im Browser. Einfach mit F12 die Entwicklertools einblenden und dann in den “Netzwerk”-Tab wechseln. Evtl. musst du noch die “Protocol”-Spalte einblenden (mit der rechten Maustaste auf die Tabellenkopfleiste klicken und “Protocol” auswählen). Wenn es aktiv ist wird dort h2 (Chrome) oder HTTP/2 (Firefox) angezeigt. Wenn es nicht aktiv ist, steht dort h1 oder http/1.1

Bildschirmfoto vom 2021-02-23 23-22-26

Ja das Modul ist aktiv:

Screenshot_20210224_053825

@bb77 lass ich dir dann zukommen, gestern auf alle Fälle ist dort Protokoll http/1.1 gestanden :confused: trotz aktiven Modul und per http/2 Test auf einer Website, sagt diese es wird kein http/2 unterstützt :slightly_frowning_face:

image

Blöde Frage: Ich nehme an du hast das mit einer Website auf dem Server, von dem wir hier reden bzw. mit deiner Nextcloud getestet? :wink:

Bessere Frage? :wink: Nutzt du mpm_prefork oder mpm_event? Damit HTTP/2 funktioniert, muss mpm_event und PHP-FPM genutzt werden bzw. aktiv sein.

Du kannst das folgendermassen einrichten:

apt install php7.4-fpm
a2dismod php7.4 && a2dismod mpm_prefork && a2enmod proxy_fcgi setenvif mpm_event && systemctl restart apache2
a2enconf php7.4-fpm && systemctl restart apache2

Hinweise:

  1. Die PHP Versionsnummer in den Befehlen muss entsprechnd der Version, die auf deinem System installiert ist, angepasst werden. Welche Version bei dir installiert ist, kannst du mit dem Befehl php -v herausfinden.
  2. Allfällige Konfigurationsänderungen, welche du in der php.ini gemacht hast, müssen in die php.ini von PHP-FPM übertragen werden.

@bb77 Natürlich habe ich dies mit meinem Server getestet mittels der Testseite :slight_smile:

Bei mir ist mpm_event aktiv und mpm_prefork deaktiviert, dennoch klappt es mittels befehl und configuration nicht, wird nach wie vor http/1.1 angezeigt in der console :frowning:

was übersehe ich :confused:

Danke für eure Zeit

Hmm. Mir fällt ehrlich gesagt auch gerade nichts mehr ein. PHP-FPM ist auch aktiv? Soviel ich weiss funktioniert es nur damit bei PHP-Anwendungen. Beschwören kann ich das aber nicht.

Screenshot_20210224_102249

setenvif ist auch geladen? Vielleicht mal alle Module anzeigen lassen…

sudo apachectl -M

PHP-FPM ist istalliert und läuft?

ps aux | grep php-fpm

Ansonsten nochmals alle Konfigurationen durchgehen. Schauen ob alle benötigten Configs und Mods aktiviert sind, die aktiviert sein müssen. Ich habe auch gesehen, dass du an unterschiedlichen Orten H2 aktiviert hast. Wenn du meine Anleitung mit der seperaten https2.conf befolgt hast, musst du es in den Virtualhost Configs nicht nochmals seperat aktiviert werden. Ansonsten wüsste ich jetzt auch nicht was man noch machen könnte…

Screenshot_20210224_105952_com.server.auditor.ssh.client

Das in den virtualhosts werde ich entfernen, war mein Fehler, danke für den Hinweis :slight_smile:

sieht gut aus soweit ich das beurteilen kann.

So ich habe dies aus der Virtualhost.conf die H2 entnommen, neu gestartet dennoch kein http/2 :frowning:
Danke dennoch für deine Bemühungen

Ich hab jz nochmals einen erfolgreichen Test gemacht, mit der Seite zum Testen von http/2 auf meinem Server, aber nextcloud selbst zeigt beim Protokoll in der console http/1.1 an

Ich betreibe nur nextcloud auf meinem pi

Oder verstehe ich was etwas falsch?

Screenshot_20210224_133811

So ich wollte mich nochmals bedankend bei euch melden,

anscheinend nach Entfernung der Zeile h2 im Virtualhost und einigen Neustarts, wurde das ganze doch dann übernommen, das mein Server h2 anzeigt, in der Console und bin endlich glücklich darüber :slight_smile:
Danke nochmals !

1 Like