|
@@ -28,18 +28,22 @@ if (processForm()) {
|
|
|
|
|
|
addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http");
|
|
|
|
|
|
+ exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['certbot_path'] . " certonly --quiet" . (CONF['ht']['letsencrypt_use_production'] ? '' : ' --test-cert') . " --key-type rsa --rsa-key-size 3072 --webroot --webroot-path /srv/niver/acme --domain " . $_POST['domain'], $output, $returnCode);
|
|
|
+ if ($returnCode !== 0)
|
|
|
+ serverError("Certbot failed to get a Let's Encrypt certificate.");
|
|
|
+
|
|
|
$nginxConf = 'server {
|
|
|
listen [' . CONF['ht']['ipv6_listen_address'] . ']:' . CONF['ht']['https_port'] . ' ssl http2;
|
|
|
listen ' . CONF['ht']['ipv4_listen_address'] . ':' . CONF['ht']['https_port'] . ' ssl http2;
|
|
|
server_name ' . $_POST['domain'] . ';
|
|
|
root ' . CONF['ht']['ht_path'] . '/' . $_SESSION['username'] . '/' . $_POST['dir'] . ';
|
|
|
|
|
|
- ssl_certificate /etc/ssl/certs/niver.crt;
|
|
|
- ssl_certificate_key /etc/ssl/private/niver.key;
|
|
|
+ ssl_certificate /etc/letsencrypt/live/' . $_POST['domain'] . '/fullchain.pem;
|
|
|
+ ssl_certificate_key /etc/letsencrypt/live/' . $_POST['domain'] . '/privkey.pem;
|
|
|
|
|
|
include inc/ht-tls.conf;
|
|
|
}
|
|
|
- ';
|
|
|
+';
|
|
|
if (file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $nginxConf) === false)
|
|
|
serverError("Failed to write Nginx configuration.");
|
|
|
|
|
@@ -49,7 +53,6 @@ if (processForm()) {
|
|
|
serverError("Failed to reload Nginx.");
|
|
|
|
|
|
success("Accès HTTP par domaine ajouté sur ce dossier !");
|
|
|
-
|
|
|
}
|
|
|
|
|
|
?>
|
|
@@ -57,8 +60,8 @@ if (processForm()) {
|
|
|
<p>
|
|
|
Ajouter un domaine sur un dossier de site<br>
|
|
|
Le domaine doit pointer vers ces adresses IP :
|
|
|
- <br>IPv4 : <code><?= CONF['ht']['ipv4_address'] ?></code>
|
|
|
<br>IPv6 : <code><?= CONF['ht']['ipv6_address'] ?></code>
|
|
|
+ <br>IPv4 : <code><?= CONF['ht']['ipv4_address'] ?></code>
|
|
|
</p>
|
|
|
|
|
|
<form method="post">
|
|
@@ -67,16 +70,12 @@ if (processForm()) {
|
|
|
<label for="dir">Dossier ciblé</label><br>
|
|
|
<select required="" name="dir" id="dir">
|
|
|
<option value="" disabled="" selected="">---</option>
|
|
|
-
|
|
|
<?php
|
|
|
|
|
|
-foreach ($dirsStatuses as $dir => $alreadyEnabled) {
|
|
|
- $disabled = $alreadyEnabled ? " disabled=''" : "";
|
|
|
- echo " <option" . $disabled . " value='" . $dir . "'>" . $dir . "</option>";
|
|
|
-}
|
|
|
+foreach ($dirsStatuses as $dir => $alreadyEnabled)
|
|
|
+ echo ' <option' . ($alreadyEnabled ? ' disabled=""' : '') . ' value="' . $dir . '">' . $dir . '</option>' . "\n";
|
|
|
|
|
|
?>
|
|
|
-
|
|
|
</select>
|
|
|
<br>
|
|
|
<input value="Valider" type="submit">
|