Protocol http servi sur port 443

J’ai des anomalies dans la conf d’un serveur apache2.4/Debian 9:

Le renouvellement de certificats Letsencrypt ne fonctionne plus. Une des causes semble être que le protocol http soit servi sur le port 443. http://webologix.com:443 par exemple affiche la page par défaut du serveur.

Tout se passe comme si le vhost défini pour ce domaine ne fonctionne pas et est redirigée vers la page Apache par défaut:

<Directory /var/www/webologix.com>
        AllowOverride None
        Require all denied
</Directory>

<VirtualHost *:443>
        DocumentRoot /var/www/webologix.com/web
        ServerName webologix.com
        ServerAlias www.webologix.com
        ServerAdmin x@xxx.com

        ErrorLog /var/log/ispconfig/httpd/webologix.com/error.log
        LogFormat "%h %l %u %t \"%r\" %>s %b" CLF
        CustomLog /var/log/ispconfig/httpd/webologix.com/access.log common
        LogLevel debug

        <Directory /var/www/webologix.com/web>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

SSLCertificateFile /etc/letsencrypt/live/webologix.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/webologix.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>

Bien que le vhost soit en mode « debug » access.log n’affiche rien

Toute suggestion appréciée. Merci

Bonjour,

une visite sur https://webologix.com affiche une erreur SSL_ERROR_RX_RECORD_TOO_LONG, et la console affiche ceci sur un wget:

wget https://webologix.com
--2020-06-16 10:19:09--  https://webologix.com/
Résolution de webologix.com (webologix.com)… 94.23.227.123
Connexion à webologix.com (webologix.com)|94.23.227.123|:443… connecté.
GnuTLS: An unexpected TLS packet was received.
Incapable d’établir une connexion SSL.

Je pense qu’il y a un problème avec la conf du VirtualHost, je mettrais plutôt ça pour la partie SSL:

	SSLEngine on
	SSLCertificateFile chemin.pem
	SSLCertificateKeyFile chemin2.pem

Essaie (ajoute la directive SSLEngine on, vérifie que les modules apache ssl sont chargés) et dis nous.

le module SSL semble chargé:

 > apache2 -t -D DUMP_MODULES | grep ssl
 ssl_module (shared)

Le SSL engine on est dans le options-ssl-apache.conf inclu:

> cat /etc/letsencrypt/options-ssl-apache.conf
# This file contains important security parameters. If you modify this file
# manually, Certbot will be unable to automatically provide future security
# updates. Instead, Certbot will print and log an error message with a path to
# the up-to-date file that you will need to refer to when manually updating
# this file.

SSLEngine on

# Intermediate configuration, tweak to your needs
SSLProtocol             all -SSLv2 -SSLv3
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
SSLHonorCipherOrder     on
SSLCompression          off

SSLOptions +StrictRequire

# Add vhost name to log entries:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" vhost_combined
LogFormat "%v %h %l %u %t \"%r\" %>s %b" vhost_common

#CustomLog /var/log/apache2/access.log vhost_combined
#LogLevel warn
#ErrorLog /var/log/apache2/error.log

# Always ensure Cookies have "Secure" set (JAH 2012/1)
#Header edit Set-Cookie (?i)^(.*)(;\s*secure)??((\s*;)?(.*)) "$1; Secure$3$4"

J’ai essayé de mettre l’include options-ssl-apache.conf au dessus:

...
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.webologix.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.webologix.com/privkey.pem
</VirtualHost>

mais ça ne change rien

Déjà une vérification de la configuration, en root :

apache2ctl -t

Ensuite on ne voit pas la configuration de l’hôte virtuel sur le port 80 et pourquoi un bloc en dehors de la définition de l’hôte virtuel ?

La syntaxe est OK. Le vhost sur le port 80:

ks307144 ~ > cat /etc/apache2/sites-enabled/100-webologix.com.vhost 

<Directory /var/www/webologix.com>
                AllowOverride None
                                Require all denied
                </Directory>

<VirtualHost *:80>

                                        DocumentRoot /var/www/clients/client1/web16/web

                ServerName webologix.com
                ServerAlias www.webologix.com
                ServerAdmin x@x.com


                ErrorLog /var/log/ispconfig/httpd/webologix.com/error.log

                Alias /error/ "/var/www/webologix.com/web/error/"
                ErrorDocument 400 /error/400.html
                ErrorDocument 401 /error/401.html
                ErrorDocument 403 /error/403.html
                ErrorDocument 404 /error/404.html
                ErrorDocument 405 /error/405.html
                ErrorDocument 500 /error/500.html
                ErrorDocument 502 /error/502.html
                ErrorDocument 503 /error/503.html

                <IfModule mod_ssl.c>
                </IfModule>

                <Directory /var/www/webologix.com/web>
                                # Clear PHP settings of this website
                                <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                                                SetHandler None
                                </FilesMatch>
                                Options +FollowSymLinks
                                AllowOverride All
                                                                Require all granted
                                                </Directory>
                <Directory /var/www/clients/client1/web16/web>
                                # Clear PHP settings of this website
                                <FilesMatch ".+\.ph(p[345]?|t|tml)$">
                                                SetHandler None
                                </FilesMatch>
                                Options +FollowSymLinks
                                AllowOverride All
                                                                Require all granted
                                                </Directory>




                # suexec enabled
                <IfModule mod_suexec.c>
                        SuexecUserGroup web16 client1
                </IfModule>
                <IfModule mod_fastcgi.c>
                                <Directory /var/www/clients/client1/web16/cgi-bin>
                                                                                Require all granted
                                                                    </Directory>
                                <Directory /var/www/webologix.com/web>
                                        <FilesMatch "\.php[345]?$">
                                                SetHandler php-fcgi
                                        </FilesMatch>
                                </Directory>
                                <Directory /var/www/clients/client1/web16/web>
                                        <FilesMatch "\.php[345]?$">
                                                SetHandler php-fcgi
                                        </FilesMatch>
                                </Directory>
                Action php-fcgi /php-fcgi virtual
                                Alias /php-fcgi /var/www/clients/client1/web16/cgi-bin/php-fcgi-*-80-webologix.com
                FastCgiExternalServer /var/www/clients/client1/web16/cgi-bin/php-fcgi-*-80-webologix.com -idle-timeout 300 -socket /var/lib/php7.0-fpm/web16.sock -pass-header Authorization  -pass-header Content-Type
                </IfModule>
                <IfModule mod_proxy_fcgi.c>
                        #ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ unix:///var/lib/php7.0-fpm/web16.sock|fcgi://localhost//var/www/clients/client1/web16/web/$1
                        <Directory /var/www/clients/client1/web16/web>
                                <FilesMatch "\.php[345]?$">
                                                SetHandler "proxy:unix:/var/lib/php7.0-fpm/web16.sock|fcgi://localhost"
                                </FilesMatch>
                        </Directory>
                        </IfModule>



                # add support for apache mpm_itk
                <IfModule mpm_itk_module>
                        AssignUserId web16 client1
                </IfModule>

                <IfModule mod_dav_fs.c>
                # Do not execute PHP files in webdav directory
                        <Directory /var/www/clients/client1/web16/webdav>
                                <ifModule mod_security2.c>
                                        SecRuleRemoveById 960015
                                        SecRuleRemoveById 960032
                                </ifModule>
                                <FilesMatch "\.ph(p3?|tml)$">
                                        SetHandler None
                                </FilesMatch>
                        </Directory>
                        DavLockDB /var/www/clients/client1/web16/tmp/DavLock
                        # DO NOT REMOVE THE COMMENTS!
                        # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
      # WEBDAV BEGIN
                        # WEBDAV END
                </IfModule>



</VirtualHost>

J’ai rentré le le bloc, même résultat:

> cat /etc/apache2/sites-enabled/webologix.com.vhost-le-ssl.conf 
<VirtualHost *:443>
        DocumentRoot /var/www/webologix.com/web
        ServerName webologix.com
        ServerAlias www.webologix.com
        ServerAdmin x@x.com

        ErrorLog /var/log/ispconfig/httpd/webologix.com/error.log
        LogFormat "%h %l %u %t \"%r\" %>s %b" CLF
        CustomLog /var/log/ispconfig/httpd/webologix.com/access.log common
        LogLevel debug
        <Directory /var/www/webologix.com>
                AllowOverride None
                Require all denied
        </Directory>


        <Directory /var/www/webologix.com/web>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/www.webologix.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.webologix.com/privkey.pem
</VirtualHost>

C’est vraiment illisible, il faut remettre en forme avec une indentation propre STP.
Après, je n’ai jamais vu une configuration aussi alambiquée pour ne pas dire carrément bordélique. C’est ispconfig qui a généré cette bouse ?

Oui, ISPCONFIG. Voilà la conf nettoyée:

<Directory /var/www/webologix.com>
	AllowOverride None
	Require all denied
</Directory>

<VirtualHost *:80>
	DocumentRoot /var/www/clients/client1/web16/web

	ServerName webologix.com
	ServerAlias www.webologix.com
	ServerAdmin webmaster@webologix.com


	ErrorLog /var/log/ispconfig/httpd/webologix.com/error.log

	Alias /error/ "/var/www/webologix.com/web/error/"
	ErrorDocument 400 /error/400.html
	ErrorDocument 401 /error/401.html
	ErrorDocument 403 /error/403.html
	ErrorDocument 404 /error/404.html
	ErrorDocument 405 /error/405.html
	ErrorDocument 500 /error/500.html
	ErrorDocument 502 /error/502.html
	ErrorDocument 503 /error/503.html

	<IfModule mod_ssl.c>
	</IfModule>

	<Directory /var/www/webologix.com/web>
		# Clear PHP settings of this website
		<FilesMatch ".+\.ph(p[345]?|t|tml)$">
			SetHandler None
		</FilesMatch>
		Options +FollowSymLinks
		AllowOverride All
		Require all granted
	</Directory>
	
	<Directory /var/www/clients/client1/web16/web>
		# Clear PHP settings of this website
		<FilesMatch ".+\.ph(p[345]?|t|tml)$">
			SetHandler None
		</FilesMatch>
		Options +FollowSymLinks
		AllowOverride All
		Require all granted
	</Directory>

	# suexec enabled
	<IfModule mod_suexec.c>
		SuexecUserGroup web16 client1
	</IfModule>
	
	<IfModule mod_fastcgi.c>
		<Directory /var/www/clients/client1/web16/cgi-bin>
			Require all granted
		</Directory>
		
		<Directory /var/www/webologix.com/web>
			<FilesMatch "\.php[345]?$">
				SetHandler php-fcgi
			</FilesMatch>
		</Directory>
		
		<Directory /var/www/clients/client1/web16/web>
			<FilesMatch "\.php[345]?$">
				SetHandler php-fcgi
			</FilesMatch>
		</Directory>

		Action php-fcgi /php-fcgi virtual
		Alias /php-fcgi /var/www/clients/client1/web16/cgi-bin/php-fcgi-*-80-webologix.com
		FastCgiExternalServer /var/www/clients/client1/web16/cgi-bin/php-fcgi-*-80-webologix.com -idle-timeout 300 -socket /var/lib/php7.0-fpm/web16.sock -pass-header Authorization  -pass-header Content-Type
	</IfModule>
	
	<IfModule mod_proxy_fcgi.c>
		#ProxyPassMatch ^/(.*\.php[345]?(/.*)?)$ unix:///var/lib/php7.0-fpm/web16.sock|fcgi://localhost//var/www/clients/client1/web16/web/$1
		<Directory /var/www/clients/client1/web16/web>
			<FilesMatch "\.php[345]?$">
				SetHandler "proxy:unix:/var/lib/php7.0-fpm/web16.sock|fcgi://localhost"
			</FilesMatch>
		</Directory>
	</IfModule>

	# add support for apache mpm_itk
	<IfModule mpm_itk_module>
			AssignUserId web16 client1
	</IfModule>

	<IfModule mod_dav_fs.c>
		# Do not execute PHP files in webdav directory
		<Directory /var/www/clients/client1/web16/webdav>
			<ifModule mod_security2.c>
				SecRuleRemoveById 960015
				SecRuleRemoveById 960032
			</ifModule>
			<FilesMatch "\.ph(p3?|tml)$">
				SetHandler None
			</FilesMatch>
		</Directory>
		DavLockDB /var/www/clients/client1/web16/tmp/DavLock
		# DO NOT REMOVE THE COMMENTS!
		# IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
		# WEBDAV BEGIN
		# WEBDAV END
	</IfModule>



</VirtualHost>

Qqchose m’étonne dans la conf générée par Letsencrypt: il ne reprend pas la conf de ISPCONFIG. Or il y a un SuexecUserGroup web16 client1 qui pourrait expliquer les pb d’accès de la version https

C’est plus lisible mais toujours aussi bordélique… Tu utilises quoi : le mod suexec, le mpm itk ou les pools php-fpm pour séparer les utilisateurs ? Le mod fastcgi ou le mod fcgid (proxy_fcgi) pour gérer le PHP ?
Bref, je n’ai pas envie de triturer ce genre de configuration horrible.

Si tu veux que ton site fonctionne en HTTPS il faut que l’hôte virtuel sur le port 443 contienne les mêmes directives que celui sur le port 80 avec en plus ses directives SSL spécifiques. Ainsi le site sera accessible en HTTP et en HTTPS.
Si tu veux qu’il ne soit accessible qu’en HTTPS, l’hôte virtuel sur le port 80 doit forcer une redirection permanente vers le HTTPS, exemple :

<VirtualHost *:80>
  ServerName example.com
  DocumentRoot /srv/web/example.com/www
  Redirect permanent / https://example.com/
</VirtualHost>
1 J'aime

bonjour,
Je vois que ton site est fonctionnel en port 80
Aurais-tu activer plusieurs site sur le même serveur , pourrais-tu nous donner la sorti de « apache2ctl -S » ?
Si tu as plusieurs site et que 1 des sites en SSL est mal configurer les autres ne fonctionneront plus.
J’avais déjà eu ce problème.

J’ai désactivé tous les vhosts sauf un pour éviter les effets de bords et simplifié la conf au minimum:

ks307144 sites-available > apachectl -S
VirtualHost configuration:
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex fcgid-proctbl: using_defaults
Mutex ssl-stapling: using_defaults
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex fcgid-pipe: using_defaults
Mutex authdigest-opaque: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex authdigest-client: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
Define: ENABLE_USR_LIB_CGI_BIN
User: name="www-data" id=33
Group: name="www-data" id=33
ks307144 sites-available > ll ../sites-enabled/
total 0
lrwxrwxrwx 1 root root 45 avril 16 09:51 000-default.conf -> /etc/apache2/sites-available/000-default.conf
lrwxrwxrwx 1 root root 37 juin  22 10:49 webologix.com.conf -> ../sites-available/webologix.com.conf
ks307144 sites-available > cat ../sites-enabled/*.conf              
<VirtualHost _default_:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog /var/log/apache2/access.log combined
</VirtualHost>

<VirtualHost *:80>

        ServerAdmin x@x.com
        DocumentRoot /var/www/webologix.com/web
        ServerName webologix.com
        ServerAlias www.webologix.com

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

        <Directory /var/www/webologix.com/web>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
        </Directory>

</VirtualHost>

Webologix.com est maintenant redirigé vers le vhost par défaut. Où est l’erreur ?!

ne renvoie rien.
Ton hôte virtuel par défaut ne sert à rien, à part montrer les informations sur le serveur web utilisé. Il devrait a minima contenir une directive ServerName.

Quel est le retour de :

apachectl -t -D DUMP_VHOSTS 

ks307144 ~ > apachectl -t -D DUMP_VHOSTS
VirtualHost configuration:

Ce n’est pas normal.
D’autres fichiers de configuration ont dû être modifiés sous /etc/apache2. En particulier voir le contenu de :

cat /etc/apache2/apache2.conf
ks307144 ~ > cat /etc/apache2/apache2.conf 

...
IncludeOptional conf-enabled/*.conf

IncludeOptional sites-enabled/*.vhost

Je comprends au passage pourquoi je ne voyais rien dans le access.log avec le other-vhosts-access-log.conf.
Est-ce ispconfig qui a pu introduire cette conf ? Je la désactive pour retrouver les logs où je m’y attends

ks307144 ~ > ll /etc/apache2/conf-enabled/*.conf
lrwxrwxrwx 1 root root   34 avril 16 09:51 /etc/apache2/conf-enabled/apache2-doc.conf -> ../conf-available/apache2-doc.conf
lrwxrwxrwx 1 root root   30 avril 16 09:51 /etc/apache2/conf-enabled/charset.conf -> ../conf-available/charset.conf
lrwxrwxrwx 1 root root   30 avril 16 09:51 /etc/apache2/conf-enabled/httpoxy.conf -> ../conf-available/httpoxy.conf
lrwxrwxrwx 1 root root   44 avril 16 09:51 /etc/apache2/conf-enabled/localized-error-pages.conf -> ../conf-available/localized-error-pages.conf
lrwxrwxrwx 1 root root   30 avril 16 09:51 /etc/apache2/conf-enabled/mailman.conf -> ../conf-available/mailman.conf
lrwxrwxrwx 1 root root   46 avril 16 09:51 /etc/apache2/conf-enabled/other-vhosts-access-log.conf -> ../conf-available/other-vhosts-access-log.conf
lrwxrwxrwx 1 root root   33 avril 16 09:51 /etc/apache2/conf-enabled/php5.6-fpm.conf -> ../conf-available/php5.6-fpm.conf
lrwxrwxrwx 1 root root   33 avril 16 09:51 /etc/apache2/conf-enabled/php7.3-fpm.conf -> ../conf-available/php7.3-fpm.conf
lrwxrwxrwx 1 root root   33 avril 16 09:51 /etc/apache2/conf-enabled/phpmyadmin.conf -> ../conf-available/phpmyadmin.conf
-rw-r--r-- 1 root root 1274 avril 16 09:51 /etc/apache2/conf-enabled/roundcube.conf
lrwxrwxrwx 1 root root   31 avril 16 09:51 /etc/apache2/conf-enabled/security.conf -> ../conf-available/security.conf
lrwxrwxrwx 1 root root   36 avril 16 09:51 /etc/apache2/conf-enabled/serve-cgi-bin.conf -> ../conf-available/serve-cgi-bin.conf

Ca fait du bien de retrouver ses logs

En fait ispconfig charge les extensions .vhost au lieu des .conf

Je vais pouvoir revoir les configs vhosts maintenant. Merci Bruno