From bd06fc7fbf914679676ad2599124577efe5155b3 Mon Sep 17 00:00:00 2001
From: Miraty
- The request is malformed.
-
- The server refused to process the request for security reasons.
-
- The server did not find anything at the requested address.
-
- Le serveur n'a rien trouvé à l'adresse demandée.
-
- The request method is not supported for this resource.
-
- The requested resource is not available anymore.
-
- Your coffee cannot be brewed because this server is a teapot.
-
- The server encountered an error and is unable to satisfy your request.
-
- Le serveur a rencontré une erreur et ne peut pas répondre à cette requête.
-
- The backend server encountered an error and is unable to satisfy your request.
-
- The server cannot handle the request, because it is overloaded or down for maintenance.
-
- Le serveur ne peut pas répondre à cette requête, car il est surchargé ou en cours de maintenance.
-
- The backend server did not send a timely response.
-
- The site you're trying to reach is misconfigured. This domain seems to be pointing to this server, but this server is not aware of a site using this domain.
-
- You reached the default site of this server directly using its IP address. There's nothing for you here.
-
- This site does not accept HTTP requests without TLS.
-
- You made a request using HTTP without TLS to the server, which refused this for privacy and security reasons, as unsecure HTTP connections can be watched and modified by any device on the way.
-
- You can replace the URI scheme
- Ce site n'accepte pas les connexions HTTP sans TLS.
-
- Vous avez envoyé une requête HTTP sans TLS au serveur, qui l'a refusée pour des raisons de sécurité et de confidentialité.
-
- Vous pouvez remplacer le schéma d'URI Bad request
- 400
-
-
diff --git a/http-errors/403.html b/http-errors/403.html
deleted file mode 100644
index 1c2fa6e..0000000
--- a/http-errors/403.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
- Access forbidden
- 403
-
-
diff --git a/http-errors/404.en.html b/http-errors/404.en.html
deleted file mode 100644
index d09c1d5..0000000
--- a/http-errors/404.en.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- File not found
-
-
- HTTP 404
-
-
diff --git a/http-errors/404.fr.html b/http-errors/404.fr.html
deleted file mode 100644
index b9748e7..0000000
--- a/http-errors/404.fr.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- Fichier introuvable
-
-
- HTTP 404
-
-
diff --git a/http-errors/404.php b/http-errors/404.php
deleted file mode 100644
index fe7d286..0000000
--- a/http-errors/404.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
- Method Not Allowed
- 405
-
-
diff --git a/http-errors/410.html b/http-errors/410.html
deleted file mode 100644
index 7b44cd6..0000000
--- a/http-errors/410.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
- Gone
- 410
-
-
diff --git a/http-errors/418.html b/http-errors/418.html
deleted file mode 100644
index fcf0bf9..0000000
--- a/http-errors/418.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
- I'm a teapot
- 418
-
-
diff --git a/http-errors/500.en.html b/http-errors/500.en.html
deleted file mode 100644
index 88a41d5..0000000
--- a/http-errors/500.en.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- Server error
-
-
- HTTP 500
-
-
diff --git a/http-errors/500.fr.html b/http-errors/500.fr.html
deleted file mode 100644
index 25926e4..0000000
--- a/http-errors/500.fr.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- Erreur du serveur
-
-
- HTTP 500
-
-
diff --git a/http-errors/500.php b/http-errors/500.php
deleted file mode 100644
index 30f23af..0000000
--- a/http-errors/500.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
- Bad gateway
-
-
- HTTP 502
-
-
diff --git a/http-errors/503.en.html b/http-errors/503.en.html
deleted file mode 100644
index 7e84963..0000000
--- a/http-errors/503.en.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- Service unavailable
-
-
- HTTP 503
-
-
diff --git a/http-errors/503.fr.html b/http-errors/503.fr.html
deleted file mode 100644
index c947e50..0000000
--- a/http-errors/503.fr.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- Service indisponible
-
-
- HTTP 503
-
-
diff --git a/http-errors/503.php b/http-errors/503.php
deleted file mode 100644
index f8ed3c2..0000000
--- a/http-errors/503.php
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
- Gateway timeout
-
-
- HTTP 504
-
-
diff --git a/http-errors/default-domain.html b/http-errors/default-domain.html
deleted file mode 100644
index c1d3c69..0000000
--- a/http-errors/default-domain.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
- Broken site
- 404
-
-
diff --git a/http-errors/default-ip.html b/http-errors/default-ip.html
deleted file mode 100644
index b12b3c8..0000000
--- a/http-errors/default-ip.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
- Nothing here
- 404
-
-
diff --git a/http-errors/index.php b/http-errors/index.php
deleted file mode 100644
index 5181e4f..0000000
--- a/http-errors/index.php
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
- TLS required
- What happened?
- How to solve this?
- http
by https
to tell your client to make the request using TLS.
- HTTP 403
-
-
diff --git a/http-errors/unsecure.fr.html b/http-errors/unsecure.fr.html
deleted file mode 100644
index 655cb2b..0000000
--- a/http-errors/unsecure.fr.html
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
- Nécessite TLS
- Que s'est-il passé ?
- Comment régler ce problème ?
- http
par https
pour indiquer à votre client de faire la requête avec TLS.
- HTTP 403
-
-
diff --git a/http-errors/unsecure.php b/http-errors/unsecure.php
deleted file mode 100644
index 3081f64..0000000
--- a/http-errors/unsecure.php
+++ /dev/null
@@ -1,7 +0,0 @@
-.htaccess configuration"
+msgstr "Configuration par .htaccess
"
#: pg-view/ht/index.php:116
-msgid "Static gzip compression is supported: if the client supports it and the file is available, path.gz
is served instead of path
."
-msgstr "La compression gzip statique est supportée : si le client le supporte et que le fichier est disponible, chemin.gz
est servi au lieu de chemin
."
-
-#: pg-view/ht/index.php:119
-msgid "Index page"
-msgstr "Page d'index"
-
-#: pg-view/ht/index.php:121
-msgid "When a request hits a directory, the first of the following files that exists inside this directory is served:"
-msgstr "Lors d'une requête sur un dossier, le premier des fichiers suivants qui existe dans ce dossier est répondu :"
-
-#: pg-view/ht/index.php:129
-msgid "404 error page"
-msgstr "Page d'erreur 404"
-
-#: pg-view/ht/index.php:131
-msgid "When a request ends in a 404
error, the first of the following files that exists at the root of the site is served:"
-msgstr "Lors d'une requête aboutissant à une erreur 404
, le premier des fichiers suivants qui existe à la racine du site est répondu :"
+msgid "You can change the way the HTTP server answers to requests in a directory by setting some directives in a file named .htaccess
at the root of this directory. Only the following directives are allowed:"
+msgstr "Vous pouvez modifier la façon dont le serveur HTTP répond aux requêtes dans un dossier en indiquant des directives dans un fichier nommé .htaccess
à la racine de ce dossier. Seules les directives suivantes sont autorisées :"
#: pg-view/ns/caa.php:3
msgid "Flag"
diff --git a/locales/messages.pot b/locales/messages.pot
index c78957b..0f27226 100644
--- a/locales/messages.pot
+++ b/locales/messages.pot
@@ -407,13 +407,13 @@ msgstr ""
msgid "No TXT record with the expected format has been found."
msgstr ""
-#: pg-act/ht/add-dns.php:59 pg-act/ht/add-onion.php:47
+#: pg-act/ht/add-dns.php:41 pg-act/ht/add-onion.php:31
#: pg-act/ht/add-subdomain.php:19 pg-act/ht/add-subpath.php:19
#, php-format
msgid "%s added on this directory."
msgstr ""
-#: pg-act/ht/add-onion.php:47
+#: pg-act/ht/add-onion.php:31
#, php-format
msgid "Its address is: %s"
msgstr ""
@@ -768,27 +768,11 @@ msgid "A content security policy (CSP) forbids Web browsers from loading JavaScr
msgstr ""
#: pg-view/ht/index.php:114
-msgid "gzip compression"
+msgid ".htaccess
configuration"
msgstr ""
#: pg-view/ht/index.php:116
-msgid "Static gzip compression is supported: if the client supports it and the file is available, path.gz
is served instead of path
."
-msgstr ""
-
-#: pg-view/ht/index.php:119
-msgid "Index page"
-msgstr ""
-
-#: pg-view/ht/index.php:121
-msgid "When a request hits a directory, the first of the following files that exists inside this directory is served:"
-msgstr ""
-
-#: pg-view/ht/index.php:129
-msgid "404 error page"
-msgstr ""
-
-#: pg-view/ht/index.php:131
-msgid "When a request ends in a 404
error, the first of the following files that exists at the root of the site is served:"
+msgid "You can change the way the HTTP server answers to requests in a directory by setting some directives in a file named .htaccess
at the root of this directory. Only the following directives are allowed:"
msgstr ""
#: pg-view/ns/caa.php:3
diff --git a/pg-act/auth/unregister.php b/pg-act/auth/unregister.php
index 708da1c..c80dffa 100644
--- a/pg-act/auth/unregister.php
+++ b/pg-act/auth/unregister.php
@@ -30,7 +30,7 @@ if (in_array('ht', $user_services, true)) {
removeDirectory(CONF['ht']['tor_config_path'] . '/' . $_SESSION['id']);
- exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['sftpgo_user'] . ' ' . CONF['ht']['rm_path'] . ' --recursive ' . CONF['ht']['ht_path'] . '/' . $_SESSION['id'], result_code: $code);
+ exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['sftpgo_user'] . ' ' . CONF['ht']['rm_path'] . ' --recursive ' . CONF['ht']['ht_path'] . '/fs/' . $_SESSION['id'], result_code: $code);
if ($code !== 0)
output(500, 'Can\'t remove user\'s directory.');
}
diff --git a/pg-act/ht/add-dns.php b/pg-act/ht/add-dns.php
index 118303e..d82e4a8 100644
--- a/pg-act/ht/add-dns.php
+++ b/pg-act/ht/add-dns.php
@@ -6,23 +6,23 @@ if (dirsStatuses('dns')[$_POST['dir']] !== false)
output(403, 'Wrong value for dir
.');
if (query('select', 'sites', ['domain' => $_POST['domain']], 'domain') !== [])
- output(403, _('This domain already exists on this service. Use another one.');
+ output(403, _('This domain already exists on this service. Use another one.'));
$remoteAaaaRecords = dns_get_record($_POST['domain'], DNS_AAAA);
if (is_array($remoteAaaaRecords) !== true)
- output(500, sprintf(_('Can\'t retrieve the %s record.'), 'AAAA');
+ output(500, sprintf(_('Can\'t retrieve the %s record.'), 'AAAA'));
if (equalArrays([CONF['ht']['ipv6_address']], array_column($remoteAaaaRecords, 'ipv6')) !== true)
output(403, sprintf(_('This domain must have %2$s as its only %1$s record.'), 'AAAA', '' . CONF['ht']['ipv6_address'] . '
'));
$remoteARecords = dns_get_record($_POST['domain'], DNS_A);
if (is_array($remoteARecords) !== true)
- output(500, sprintf(_('Can\'t retrieve the %s record.'), 'A');
+ output(500, sprintf(_('Can\'t retrieve the %s record.'), 'A'));
if (equalArrays([CONF['ht']['ipv4_address']], array_column($remoteARecords, 'ip')) !== true)
output(403, sprintf(_('This domain must have %2$s as its only %1$s record.'), 'A', '' . CONF['ht']['ipv4_address'] . '
'));
$remoteTXTRecords = dns_get_record($_POST['domain'], DNS_TXT);
if (is_array($remoteTXTRecords) !== true)
- output(500, sprintf(_('Can\'t retrieve the %s record.'), 'TXT');
+ output(500, sprintf(_('Can\'t retrieve the %s record.'), 'TXT'));
if (preg_match('/^' . preg_quote(SERVER_NAME, '/') . '_domain-verification=([0-9a-f]{8})-([0-9a-f]{32})$/Dm', implode(LF, array_column($remoteTXTRecords, 'txt')), $matches) !== 1)
output(403, _('No TXT record with the expected format has been found.'));
@@ -36,24 +36,6 @@ exec('2>&1 ' . CONF['ht']['sudo_path'] . ' ' . CONF['ht']['certbot_path'] . ' ce
if ($returnCode !== 0)
output(500, 'Certbot failed to get a Let\'s Encrypt certificate.', $output);
-$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['id'] . '/' . $_POST['dir'] . ';
+htRelativeSymlink('../fs/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['ht_path'] . '/uri/' . $_POST['domain']);
- 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)
- output(500, 'Failed to write Nginx configuration.');
-
-// Reload Nginx
-exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['nginx_reload_cmd'], result_code: $code);
-if ($code !== 0)
- output(500, 'Failed to reload Nginx.');
-
-output(200, sprintf(_('%s added on this directory.'), PAGE_METADATA['title']);
+output(200, sprintf(_('%s added on this directory.'), PAGE_METADATA['title']));
diff --git a/pg-act/ht/add-onion.php b/pg-act/ht/add-onion.php
index bf39f61..93b674a 100644
--- a/pg-act/ht/add-onion.php
+++ b/pg-act/ht/add-onion.php
@@ -7,8 +7,7 @@ rateLimit();
// Add Tor config
$torConf = 'HiddenServiceDir ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'] . '/
-HiddenServicePort 80 unix:' . CONF['ht']['http_onion_socket'] . '
-';
+HiddenServicePort 80 ' . CONF['ht']['onion_internal_host'] . LF;
if (file_put_contents(CONF['ht']['tor_config_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'], $torConf) === false)
output(500, 'Failed to write new Tor configuration.');
@@ -26,22 +25,7 @@ if (preg_match('/^[0-9a-z]{56}\.onion$/D', $onion) !== 1)
// Store it in the database
addSite($_SESSION['id'], $_POST['dir'], $onion, 'onion');
-// Add Nginx config
-$nginxConf = 'server {
- listen unix:' . CONF['ht']['http_onion_socket'] . ';
- server_name ' . $onion . ';
- root ' . CONF['ht']['ht_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'] . ';
-
- include inc/ht-onion.conf;
-}
-';
-if (file_put_contents(CONF['ht']['nginx_config_path'] . '/' . $onion . '.conf', $nginxConf) === false)
- output(500, 'Failed to write Nginx configuration.');
-
-// Reload Nginx
-exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['nginx_reload_cmd'], result_code: $code);
-if ($code !== 0)
- output(500, 'Failed to reload Nginx.');
+htRelativeSymlink('../fs/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['ht_path'] . '/uri/' . $onion);
// Tell the user their site address
output(200, sprintf(_('%s added on this directory.'), PAGE_METADATA['title']) . ' ' . sprintf(_('Its address is: %s'), 'http://' . $onion . '/
'));
diff --git a/pg-act/ht/add-subdomain.php b/pg-act/ht/add-subdomain.php
index 30d35ef..8bd2c96 100644
--- a/pg-act/ht/add-subdomain.php
+++ b/pg-act/ht/add-subdomain.php
@@ -13,7 +13,7 @@ rateLimit();
addSite($_SESSION['id'], $_POST['dir'], $_POST['subdomain'], 'subdomain');
-if (symlink(CONF['ht']['ht_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['subdomain_path'] . '/' . $_POST['subdomain']) !== true)
+if (symlink('../../fs/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['ht_path'] . '/uri/' . $_POST['subdomain'] . '.' . CONF['ht']['subdomain_domain']) !== true)
output(500, 'Unable to create symlink.');
output(200, sprintf(_('%s added on this directory.'), PAGE_METADATA['title']));
diff --git a/pg-act/ht/add-subpath.php b/pg-act/ht/add-subpath.php
index e4b129f..8f83761 100644
--- a/pg-act/ht/add-subpath.php
+++ b/pg-act/ht/add-subpath.php
@@ -13,7 +13,7 @@ rateLimit();
addSite($_SESSION['id'], $_POST['dir'], $_POST['path'], 'subpath');
-if (symlink(CONF['ht']['ht_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['subpath_path'] . '/' . $_POST['path']) !== true)
+if (symlink('../../fs/' . $_SESSION['id'] . '/' . $_POST['dir'], CONF['ht']['ht_path'] . '/uri/' . CONF['ht']['subpath_domain'] . '/' . $_POST['path']) !== true)
output(500, 'Unable to create symlink.');
output(200, sprintf(_('%s added on this directory.'), PAGE_METADATA['title']));
diff --git a/pg-view/ht/index.php b/pg-view/ht/index.php
index c196d38..28c8168 100644
--- a/pg-view/ht/index.php
+++ b/pg-view/ht/index.php
@@ -111,28 +111,57 @@ $quota = ($_SESSION['type'] ?? '' === 'approved') ? CONF['ht']['user_quota_appro
= _('A content security policy (CSP) forbids Web browsers from loading JavaScript or third-party resources.') ?>
.htaccess
configuration') ?>
- = _('Static gzip compression is supported: if the client supports it and the file is available, path.gz
is served instead of path
.') ?>
+ = _('You can change the way the HTTP server answers to requests in a directory by setting some directives in a file named .htaccess
at the root of this directory. Only the following directives are allowed:') ?>
<Files>
<FilesMatch>
- = _('When a request hits a directory, the first of the following files that exists inside this directory is served:') ?> -
-index.html
index.md
index.gmi
Redirect
RedirectMatch
RedirectPermanent
RedirectTemp
- = _('When a request ends in a 404
error, the first of the following files that exists at the root of the site is served:') ?>
-
404.html
404.md
404.gmi
ErrorDocument
AddType
ForceType
DefaultLanguage
AddLanguage
LanguagePriority
ForceLanguagePriority
DirectoryIndex
DirectorySlash
RemoveType
RemoveOutputFilter
RemoveLanguage
RemoveEncoding
RemoveCharset
ExpiresActive
ExpiresDefault
ExpiresByType
DefaultIcon
AddDescription
AddAlt
AddAltByEncoding
AddAltByType
AddIcon
AddIconByEncoding
AddIconByType
IndexIgnore
IndexIgnoreReset
IndexOptions
IndexOrderDefault
HeaderName
ReadmeName
IndexStyleSheet