Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1883 connectés 

  FORUM HardWare.fr
  Linux et OS Alternatifs
  Logiciels

  ubuntu, apache2, nextcloud, reverse proxy et certbot certificat expire

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

ubuntu, apache2, nextcloud, reverse proxy et certbot certificat expire

n°1486236
Arjuna
Aircraft Ident.: F-MBSD
Posté le 04-09-2023 à 20:20:15  profilanswer
 

Bonjour,

 

Avant de tout expliquer, voici mon souci : le certificat SSL obtenu auprès de letsencrypt.org pour mon domaine cloud.manga-torii.com arrive à expiration dans quelques jours, et certbot n'arrive pas à le renouveler.
Visiblement la faute au port 80 qui fait n'importe quoi et j'arrive pas à comprendre d'où ça vient.

 

Voici mon architecture :

 

J'ai deux machine sous Linux, dans le même réseau.

 

La première, une VM hébergée dans ma box, que je vais appeler "owncloud"... qui contrairement à ce que son nom indique, ne fait pas tourner owncloud...  [:atari]

 

Une seconde, sur une machine physique, que je vais appeler "mycloud"... qui ne fait pas tourner non plus owncloud, mais nextcloud (je sens que ça va être simple à expliquer mon bordel)  [:totoz]

 

Sur la machine "mycloud" j'ai installé Nextcloud, en respectant scrupuleusement le manuel : https://docs.nextcloud.com/server/s [...] ation.html
Je ne suis pas passé par Docker ou autre, j'y suis allé à la mano, en utilisant tout de même le web installer.

 

J'ai choisi apache2 comme serveur web, et voici quelques éléments de configuration de ce dernier :


<VirtualHost *:80>
  DocumentRoot /var/www/nextcloud/
  ServerName cloud.manga-torii.com

 

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

 

   <IfModule mod_dav.c>
      Dav off
    </IfModule>

 

 </Directory>
</VirtualHost>


Déjà, première question : vu que ce serveur est appelé uniquement par le reverse proxy par l'adresse http://192.168.0.35 en quoi est-ce utile d'indiquer le "ServerName" ? C'est pas censé filtrer la config en fonction du nom d'hôte utilisé pour atteindre le serveur ?

 


Sur le serveur "owncloud", qui fait office de reverse proxy, j'ai choisi aussi apache2 (pour la simple et bonne raison qu'à l'origine il y avait d'autres sites hébergés dessus).
Là, ça se corse, le fichier de config est plus complexe, merci Collabora Online...

 

Premier fichier de config (pour le port 443) :


<IfModule mod_ssl.c>
<VirtualHost *:443>
    ServerName cloud.manga-torii.com
    ServerAlias cloud.manga-torii.com
    ServerAdmin administrateur@manga-torii.com

 

   ProxyPreserveHost On
    ProxyPass "/"  "http://192.168.0.35/"
    ProxyPassReverse "/"  "http://192.168.0.35/"

 

Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/cloud.manga-torii.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/cloud.manga-torii.com/privkey.pem

 

   <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^/\.well-known/carddav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
        RewriteRule ^/\.well-known/caldav https://%{SERVER_NAME}/remote.php/dav/ [R=301,L]
    </IfModule>

 

RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-SSL on

 

   <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
    </IfModule>

 

</VirtualHost>
</IfModule>


Première chose bizarre : si je n'active que ce fichier de configuration, un appel à :
https://cloud.manga-torii.com fonctionne (jusque là tout va bien)
http://cloud.manga-torii.com ... fonctionne aussi ! on reçoit une redirection 301 vers https://cloud.manga-torii.com ! là je commence déjà à être largué

 

Il y a bien le fichier de config 000-default.conf qui est actif aussi, mais je ne vois pas le rapport avec la redirection 403... et surtout j'arrive pas du tout dans son DocumentRoot !


<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

 

       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
</VirtualHost>

 

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


Dans /var/www/html il y a le index.html standard d'apache, et c'est pas lui qui s'affiche...

 


certbot apparemment ne sait pas utiliser HTTPS, uniquement HTTP, donc d'entrée, quand il essaie d'appeler mon site, il se prend un 403 qui l'envoie sur du HTTPS, et ça doit coincer ici.

 

D'où peut venir cette redirection ?

 

J'ai aussi ufw et fail2ban sur le serveur "owncloud", mais quand je les désactive ça change rien, donc visiblement il n'y sont pour rien...


Message édité par Arjuna le 04-09-2023 à 20:55:42
mood
Publicité
Posté le 04-09-2023 à 20:20:15  profilanswer
 

n°1486237
Arjuna
Aircraft Ident.: F-MBSD
Posté le 04-09-2023 à 20:43:38  profilanswer
 

Hmpf, je viens de trouver pourquoi y'a un écrasement du protocole HTTP par HTTPS, la faute à ces deux lignes dans la config du site en HTTPS : (pas logique je trouve mais bon)


RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-SSL on


Bon, ok, j'ai mis en commentaire.

 

=> http://cloud.manga-torii.com répond plus : ERR_CONNECTION_REFUSED

 

Mais pourquoi tant de haine ? Le 000-default.conf devrait me servir le index.html d'apache...

 

Je le désactive, et je met un nouveau :


<VirtualHost cloud.manga-torii.com:80>
    ServerName cloud.manga-torii.com
    ServerAlias cloud.manga-torii.com
    ServerAdmin administrateur@manga-torii.com

 

   ProxyPreserveHost On
    ProxyRequests On
    ProxyPass /  http://192.168.0.35/
    ProxyPassReverse /  http://192.168.0.35
</VirtualHost>


Là je pige vraiment rien... Ca me refait un redirect...
Bon, après, peut-être la faute aux fichiers de config de Nextcloud : à cause de Collabora Online et du fait qu'il est derrière un reverseproxy, j'ai du bidouiller pour forcer la connexion en HTTPS un peu partout...

 


Mais ça marche toujours pas...


moi@owncloud:~$ sudo certbot renew -v
Saving debug log to /var/log/letsencrypt/letsencrypt.log

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/cloud.manga-torii.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Certificate is due for renewal, auto-renewing...
Plugins selected: Authenticator apache, Installer apache
Renewing an existing certificate for cloud.manga-torii.com
Performing the following challenges:
http-01 challenge for cloud.manga-torii.com
Waiting for verification...
Challenge failed for domain cloud.manga-torii.com
http-01 challenge for cloud.manga-torii.com

 

Certbot failed to authenticate some domains (authenticator: apache). The Certificate Authority reported these problems:
  Domain: cloud.manga-torii.com
  Type:   connection
  Detail: 82.65.141.110: Fetching http://cloud.manga-torii.com/.well-known/acme-challenge/<****************>: Timeout during connect (likely firewall problem)

 

Hint: The Certificate Authority failed to verify the temporary Apache configuration changes made by Certbot. Ensure that the listed domains point to this Apache server and that it is accessible from the internet.

 

Cleaning up challenges
Failed to renew certificate cloud.manga-torii.com with error: Some challenges have failed.

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
All renewals failed. The following certificates could not be renewed:
  /etc/letsencrypt/live/cloud.manga-torii.com/fullchain.pem (failure)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1 renew failure(s), 0 parse failure(s)
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.

 

Je pige vraiment pas ce qu'il se passe...


Message édité par Arjuna le 04-09-2023 à 20:50:33
n°1486238
Arjuna
Aircraft Ident.: F-MBSD
Posté le 04-09-2023 à 20:55:23  profilanswer
 

Même si j'appelle un fichier non interprété, j'ai la redirection...
 
http://cloud.manga-torii.com/resources/locales.json
=> Ca charge https://cloud.manga-torii.com/resources/locales.json
 
Cette fois c'est plus une redirection 301 mais une 307 [:magicbuzz]

n°1486239
Arjuna
Aircraft Ident.: F-MBSD
Posté le 04-09-2023 à 21:16:19  profilanswer
 

Bon, après je viens de voir sur stackoverflow que c'est pas un souci de HTTP... CertBot sait suivre un 301 vers du HTTPS, c'est juste qu'il faut que le point d'entrée soit bien du HTTP sur le port 80.
 
Du coup je pige plus rien...
 
Pourquoi ça marche pas ? :cry:

n°1486244
Je@nb
Kindly give dime
Posté le 05-09-2023 à 00:06:30  profilanswer
 

C'est pas ouvert de l'extérieur le port 80 à priori :o
En tout cas chez moi ça répond pas.
Tu as pas du faire de redirection de port sur ta box

n°1486246
renaud072
Posté le 05-09-2023 à 01:11:32  profilanswer
 

Je confirme chez moi aussi l’absence du port 80 :  

~$ nmap cloud.manga-torii.com
Starting Nmap 7.80 ( https://nmap.org ) at 2023-09-05 01:05 CEST
Nmap scan report for cloud.manga-torii.com (82.65.141.110)
Host is up (0.035s latency).
rDNS record for 82.65.141.110: 82-65-141-110.subs.proxad.net
Not shown: 999 filtered ports
PORT    STATE SERVICE
443/tcp open  https
 
Nmap done: 1 IP address (1 host up) scanned in 4.49 seconds


---------------
MSI B450 Tomahawk MAX - R7 3700X - Ballistix 2x8 + 2x16 Go 3200 Mhz CL16 - RX570 4 Go / Laptop : Lenovo Gaming 3 - R5 5600H - RX Vega 8/GTX 1650 - 32 Go
n°1486250
Arjuna
Aircraft Ident.: F-MBSD
Posté le 05-09-2023 à 08:10:36  profilanswer
 

Je@nb a écrit :

C'est pas ouvert de l'extérieur le port 80 à priori :o
En tout cas chez moi ça répond pas.
Tu as pas du faire de redirection de port sur ta box


Hmpf la box... Lol j'y avais plus pensé.  [:aokiji]

 

J'me sens con d'un coup :sweat:

 


moi@owncloud:~$ sudo certbot renew
[sudo] password for moi:
Saving debug log to /var/log/letsencrypt/letsencrypt.log

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/cloud.manga-torii.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Renewing an existing certificate for cloud.manga-torii.com and drive.manga-torii.com
Reloading apache server after certificate renewal

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Processing /etc/letsencrypt/renewal/drive.manga-torii.com.conf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Renewing an existing certificate for drive.manga-torii.com and 2 more domains
Reloading apache server after certificate renewal

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations, all renewals succeeded:
  /etc/letsencrypt/live/cloud.manga-torii.com/fullchain.pem (success)
  /etc/letsencrypt/live/drive.manga-torii.com/fullchain.pem (success)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


Message édité par Arjuna le 05-09-2023 à 09:08:23

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Linux et OS Alternatifs
  Logiciels

  ubuntu, apache2, nextcloud, reverse proxy et certbot certificat expire

 

Sujets relatifs
[NextCloud] Problème avec Collabora Online et reverse proxyRÉSOLU - Booter sur clé USB après install Ubuntu 23.04 Cinnamon
Meilleurs jeux video pour UbuntuProblème serveur VNC (x11vnc, tightvnc) pour Ubuntu 20.04
Nextcloud avec collabora built-in derriere un reverse proxy[UBUNTU] Lancer Ubuntu au démarrage depuis un HDD externe USB?
Plus de sujets relatifs à : ubuntu, apache2, nextcloud, reverse proxy et certbot certificat expire


Copyright © 1997-2025 Groupe LDLC (Signaler un contenu illicite / Données personnelles)