Arret d'apache sans raison

Tags: #<Tag:0x00007f63f16980c8> #<Tag:0x00007f63f1f07f60>

bjr,
j’ai un petit server en prod et ce matin je n’avais plus de server web… et je ne comprends pas pourquoi !!! pouvez vous m’aider a comprendre ce qui s’est passer??? ma debian est a jour…
et je ne vois rien dans mon syslog…mais je ne suis pas un pro…
bug, attaque, tentative???
Merci pour votre aide

Regarde les logs spécifique d’apache pour commencer et aussi tout ce qui touche au matériel pour voir si il y a pas eu un OOM.

La première chose à faire, c’est arrêter de paniquer. Assieds-toi, prends une grand inspiration et expire lentement pour faire redescendre la pression. La panique augmente énormément le risque de suraccident.
Une fois que tu as fait ça, tu peux revenir ici avec des journaux et plus de détails sur le système.

Ca correspond a quoi ca???

Jan 26 23:30:10 Next dhclient[614]: No working leases in persistent database - sleeping.
Jan 26 23:30:45 Next systemd[1]: apache2.service: Main process exited, code=exited, status=1/FAILURE
Jan 26 23:30:45 Next systemd[1]: apache2.service: Killing process 1564401 (apache2) with signal SIGKILL.
Jan 26 23:30:45 Next systemd[1]: apache2.service: Killing process 1564402 (apache2) with signal SIGKILL.
Jan 26 23:30:45 Next systemd[1]: apache2.service: Failed with result 'exit-code'.
Jan 26 23:30:45 Next systemd[1]: apache2.service: Consumed 1h 56min 3.732s CPU time.

Maintenant tu sais que c’est à 23:30:45 que ton serveur apache a été coupé.
Regarde les logs spécifiques du service, autour de cette heure: journalctl -u apache2

j’ai rien d’autre!!!

janv. 26 20:39:33 Next postfix/smtpd[1562602]: 5415B15F6F9: client=localhost[127.0.0.1]
janv. 26 20:39:33 Next postfix/smtpd[1562602]: disconnect from localhost[127.0.0.1] helo=1 mail=1 rcpt=3 data=1 quit=1 commands=7
janv. 26 23:30:45 Next systemd[1]: apache2.service: Main process exited, code=exited, status=1/FAILURE
janv. 26 23:30:45 Next systemd[1]: apache2.service: Killing process 1564401 (apache2) with signal SIGKILL.
janv. 26 23:30:45 Next systemd[1]: apache2.service: Killing process 1564402 (apache2) with signal SIGKILL.
janv. 26 23:30:45 Next systemd[1]: apache2.service: Failed with result 'exit-code'.
janv. 26 23:30:45 Next systemd[1]: apache2.service: Consumed 1h 56min 3.732s CPU time.
janv. 27 07:18:33 Next systemd[1]: Starting The Apache HTTP Server...
janv. 27 07:18:33 Next systemd[1]: Started The Apache HTTP Server.

7:18 c’est moi…

janv. 26 23:25:38 Next systemd[1]: Starting Certbot...
janv. 26 23:29:09 Next dhclient[614]: DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 3
janv. 26 23:29:12 Next dhclient[614]: DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 6
janv. 26 23:29:18 Next dhclient[614]: DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 13
janv. 26 23:29:31 Next dhclient[614]: DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 8
janv. 26 23:29:39 Next dhclient[614]: DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 12
janv. 26 23:29:51 Next dhclient[614]: DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 19
janv. 26 23:30:10 Next dhclient[614]: No DHCPOFFERS received.
janv. 26 23:30:10 Next dhclient[614]: No working leases in persistent database - sleeping.
janv. 26 23:30:45 Next systemd[1]: apache2.service: Main process exited, code=exited, status=1/FAILURE
janv. 26 23:30:45 Next systemd[1]: apache2.service: Killing process 1564401 (apache2) with signal SIGKILL.
janv. 26 23:30:45 Next systemd[1]: apache2.service: Killing process 1564402 (apache2) with signal SIGKILL.
janv. 26 23:30:45 Next systemd[1]: apache2.service: Failed with result 'exit-code'.
janv. 26 23:30:45 Next systemd[1]: apache2.service: Consumed 1h 56min 3.732s CPU time.
janv. 26 23:30:47 Next certbot[1564379]: Challenge failed for domain xxxxx.fr
janv. 26 23:30:47 Next certbot[1564379]: Challenge failed for domain www.xxxxx.fr
janv. 26 23:30:47 Next certbot[1564379]: Failed to renew certificate xxxxx.fr with error: Some challenges have failed.
janv. 26 23:30:51 Next certbot[1564379]: All renewals failed. The following certificates could not be renewed:
janv. 26 23:30:51 Next certbot[1564379]:   /etc/letsencrypt/live/xxxxx.fr/fullchain.pem (failure)
janv. 26 23:30:51 Next certbot[1564379]: 1 renew failure(s), 0 parse failure(s)
janv. 26 23:30:51 Next systemd[1]: certbot.service: Main process exited, code=exited, status=1/FAILURE
janv. 26 23:30:52 Next systemd[1]: certbot.service: Failed with result 'exit-code'.
janv. 26 23:30:52 Next systemd[1]: Failed to start Certbot.
janv. 26 23:30:52 Next systemd[1]: certbot.service: Consumed 5.697s CPU time.
janv. 26 23:33:47 Next dhclient[614]: DHCPDISCOVER on eno1 to 255.255.255.255 port 67 interval 5

cerbot serait l’erreur… je ne vois pas pourquoi apache a stoper…

Au vue du log ce ne serait pas ton Certbot qui aurait stopper ton apache, par contre à savoir pourquoi il ne l’a pas redémarré ?

Si tu le fais à l’aide d’une tâche cron comme ça,

/usr/bin/certbot renew --pre-hook "systemctl stop apache2" --post-hook "systemctl start apache2"

et que le renouvellement ai échoué, il serait du coup logique qu’il n’est pas redémarré ton apache … à voir

oui je suis d’acccord avec toi

C’est simple, pas d’adresse DHCP fournie au client, donc pas de bind du serveur apache, seul l(interface lo est disponible:

1 J'aime

Mais dans mon cas c’est pas cas…je suis en ip fixe j’ai simple bloqué les communications dans le serveur DHCP…et mon server était tjrs accessible avec ssh…donc c’est pas ça…

Bonjour,

Montre-nous :

systemctl list-timers

Les logs de certbot (/var/log/letsencrypt/letsencrypt.log) au moment où cela foire.
Dis-nous si tu as modifié des fichiers de configuration de certbot ou sa tâche cron.

Et il y a sans doute un problème au niveau de la configuration réseau : ce n’est pas normal que la carte eno1 cherche à obtenir une IP en DHCP si elle a une IP fixe.

1 J'aime
systemctl list-timers
NEXT                        LEFT           LAST                        PASSED       UNIT                         ACTIVATES
Fri 2022-01-28 10:39:00 CET 10min left     Fri 2022-01-28 10:09:02 CET 19min ago    phpsessionclean.timer        phpsessionclean.service
Fri 2022-01-28 13:13:05 CET 2h 44min left  Thu 2022-01-27 13:13:05 CET 21h ago      systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Fri 2022-01-28 14:47:34 CET 4h 19min left  Thu 2022-01-27 21:42:25 CET 12h ago      apt-daily.timer              apt-daily.service
Fri 2022-01-28 21:59:51 CET 11h left       Fri 2022-01-28 04:45:10 CET 5h 43min ago certbot.timer                certbot.service
Sat 2022-01-29 00:00:00 CET 13h left       Fri 2022-01-28 00:00:00 CET 10h ago      logrotate.timer              logrotate.service
Sat 2022-01-29 00:00:00 CET 13h left       Fri 2022-01-28 00:00:00 CET 10h ago      man-db.timer                 man-db.service
Sat 2022-01-29 00:24:16 CET 13h left       Fri 2022-01-28 00:20:38 CET 10h ago      lynis.timer                  lynis.service
Sat 2022-01-29 06:11:33 CET 19h left       Fri 2022-01-28 06:22:21 CET 4h 6min ago  apt-daily-upgrade.timer      apt-daily-upgrade.service
Sun 2022-01-30 03:10:17 CET 1 day 16h left Sun 2022-01-23 03:10:42 CET 5 days ago   e2scrub_all.timer            e2scrub_all.service

9 timers listed.
Pass --all to see loaded but inactive timers, too.
 /etc/letsencrypt/live/xxxxxx.com/fullchain.pem expires on 2022-03-29 (skipped)
2022-01-26 23:30:51,654:ERROR:certbot._internal.renewal:All renewals failed. The following certificates could not be renewed:
2022-01-26 23:30:51,655:ERROR:certbot._internal.renewal:  /etc/letsencrypt/live/XXXXXX.fr/fullchain.pem (failure)
2022-01-26 23:30:51,655:DEBUG:certbot.display.util:Notifying user: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2022-01-26 23:30:51,656:DEBUG:certbot._internal.log:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/bin/certbot", line 33, in <module>
    sys.exit(load_entry_point('certbot==1.12.0', 'console_scripts', 'certbot')())
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 15, in main
    return internal_main.main(cli_args)
  File "/usr/lib/python3/dist-packages/certbot/_internal/main.py", line 1413, in main
    return config.func(config, plugins)
  File "/usr/lib/python3/dist-packages/certbot/_internal/main.py", line 1317, in renew
    renewal.handle_renewal_request(config)
  File "/usr/lib/python3/dist-packages/certbot/_internal/renewal.py", line 510, in handle_renewal_request
    raise errors.Error("{0} renew failure(s), {1} parse failure(s)".format(
certbot.errors.Error: 1 renew failure(s), 0 parse failure(s)
2022-01-26 23:30:51,658:ERROR:certbot._internal.log:1 renew failure(s), 0 parse failure(s)
2022-01-27 00:55:01,540:DEBUG:certbot._internal.main:certbot version: 1.12.0
2022-01-27 00:55:01,541:DEBUG:certbot._internal.main:Location of certbot entry point: /usr/bin/certbot
2022-01-27 00:55:01,541:DEBUG:certbot._internal.main:Arguments: ['-q']
2022-01-27 00:55:01,541:DEBUG:certbot._internal.main:Discovered plugins: PluginsRegistry(PluginEntryPoint#apache,PluginEntryPoint#manual,PluginEntryPoint#null,PluginEntryPoint#standalone,Pl>
2022-01-27 00:55:01,568:DEBUG:certbot._internal.log:Root logging level set at 30
2022-01-27 00:55:01,568:INFO:certbot._internal.log:Saving debug log to /var/log/letsencrypt/letsencrypt.log

a 12h00 j’ai un script qui fait

#!/bin/bash
certbot renew  &&  service apache2 reload

Ce n’est pas au niveau du serveur que cela se fait mais au niveau client.
Le système DHCP est un protocole dont les communication sont gérées par le client. Donc c’est au client d’arrêter de demander une adresse DHCP.

Tu n’as pas besoin de ce script le paquet certbot installe la tâche cron (sous /etc/cron.d) et les timer et service systemd qui vont bien. Si le redémarrage d’Apache est nécessire il ne faut pas le placer là, mais dans un fichier sous /etc/letsencrypt/renewal-hooks/deploy/ (ou utiliser --deploy-hook)

Le renouvellement d’un certificat échoue mais on ne sait pas pourquoi. Il faut essayer en ligne de commande pour voir ce qui cloche :

certbot --dry-run renew

effectivement j’ai des erreurs sur les noms de domaine…

Cert not due for renewal, but simulating renewal for dry run
Plugins selected: Authenticator apache, Installer apache
Simulating renewal of an existing certificate for xxxx.fr and www.xxxxx.fr
Performing the following challenges:
http-01 challenge for xxx.fr
http-01 challenge for www.xxxx.fr
Waiting for verification...
Challenge failed for domain www.xxxxx.fr
Challenge failed for domain xxxx.fr
http-01 challenge for www.xxxxx.fr
http-01 challenge for xxxx.fr
Cleaning up challenges
Failed to renew certificate xxxxx.fr with error: Some challenges have failed.

Il n’y a pas plus d’informations que cela ?
Peut-être qu’il y a d’autres infos dans les logs.
Il faut commencer par vérifier que Apache est bien lancé et que xxx.fr et www.xxx.fr (pourquoi cacher le nom de domaine?) pointent bien vers ton IP.