Merge pull request #3133 from nextcloud/enh/noid/add-domain-validator

add domain-validator
This commit is contained in:
Simon L 2023-08-10 13:20:37 +02:00 committed by GitHub
commit 725bbb7c05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 6 deletions

View file

@ -14,18 +14,17 @@
servers {
protocols h1 h2 h2c
}
on_demand_tls {
ask http://localhost:9876/
}
}
http://:80 {
redir https://{host}{uri}
}
# Match only host names and not ip-addresses:
https://*.*:8443,
https://*.*.*:8443,
https://*.*.*.*:8443,
https://*.*.*.*.*:8443,
https://*.*.*.*.*.*:8443 {
https://:8443 {
reverse_proxy localhost:8000

View file

@ -55,3 +55,11 @@ stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=/session-deduplicator.sh
user=root
[program:domain-validator]
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
command=php -S 127.0.0.1:9876 /var/www/docker-aio/php/domain-validator.php
user=www-data

17
php/domain-validator.php Normal file
View file

@ -0,0 +1,17 @@
<?php
$domain = $_GET['domain'] ?? '';
if (strpos($domain, '.') === false) {
http_response_code(400);
} elseif (strpos($domain, '/') !== false) {
http_response_code(400);
} elseif (strpos($domain, ':') !== false) {
http_response_code(400);
} elseif (!filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_IP)) {
http_response_code(400);
} else {
http_response_code(200);
}