Apache protect more non-public folders and files (#6881)

* Apache protect more non-public folders

* Also protect root

* Do the same for /p/

* Simplify Require all denied
In case of Apache 2.2, it will just make an error 500 instead of 403

* .htaccess.dist

* Simplify

* Better comment
This commit is contained in:
Alexandre Alapetite
2024-10-11 09:25:43 +02:00
committed by GitHub
parent b30a8fa652
commit 91624037c7
17 changed files with 67 additions and 57 deletions

1
.devcontainer/.htaccess Normal file
View File

@@ -0,0 +1 @@
Require all denied

1
.github/.htaccess vendored Normal file
View File

@@ -0,0 +1 @@
Require all denied

5
.gitignore vendored
View File

@@ -1,10 +1,11 @@
/.htaccess
/bin/
/constants.local.php
/data.back/
/extensions/node_modules/
/extensions/vendor/
/node_modules/
/vendor/
/data.back/
/constants.local.php
.vscode/

7
.htaccess.dist Normal file
View File

@@ -0,0 +1,7 @@
# Copy this file to `.htaccess` for additional root-level protection
# if you cannot set Apache `DocumentRoot` to `./p/` as recommended.
# Deny files starting with a dot, or without extension, or not in a whitelist of extensions
<FilesMatch "^\.|^[^.]+$|\.(?!css|gif|html|ico|js|php|png|svg|txt|woff|woff2)[^.]*$">
Require all denied
</FilesMatch>

1
Docker/.htaccess Normal file
View File

@@ -0,0 +1 @@
Require all denied

View File

@@ -1,11 +1 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
Order Allow,Deny
Deny from all
Satisfy all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
Require all denied

View File

@@ -1,11 +1 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
Order Allow,Deny
Deny from all
Satisfy all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
Require all denied

View File

@@ -25,17 +25,7 @@ foreach ($dirs as $dir) {
}
file_put_contents(DATA_PATH . '/.htaccess', <<<'EOF'
# Apache 2.2
<IfModule !mod_authz_core.c>
Order Allow,Deny
Deny from all
Satisfy all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
Require all denied
EOF
);

View File

@@ -1,11 +1 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
Order Allow,Deny
Deny from all
Satisfy all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
Require all denied

1
docs/.htaccess Normal file
View File

@@ -0,0 +1 @@
Require all denied

1
extensions/.htaccess Normal file
View File

@@ -0,0 +1 @@
Require all denied

13
extensions/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Refresh" content="0; url=/" />
<title>Redirection</title>
<meta name="robots" content="noindex" />
</head>
<body>
<p><a href="/">Redirection</a></p>
</body>
</html>

View File

@@ -1,11 +1 @@
# Apache 2.2
<IfModule !mod_authz_core.c>
Order Allow,Deny
Deny from all
Satisfy all
</IfModule>
# Apache 2.4
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
Require all denied

13
lib/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Refresh" content="0; url=/" />
<title>Redirection</title>
<meta name="robots" content="noindex" />
</head>
<body>
<p><a href="/">Redirection</a></p>
</body>
</html>

View File

@@ -1,3 +1,10 @@
<IfModule mod_authz_core.c>
# Deny files starting with a dot, or without extension, or not in a whitelist of extensions
<FilesMatch "^\.|^[^.]+$|\.(?!css|gif|html|ico|js|php|png|svg|txt|woff|woff2)[^.]*$">
Require all denied
</FilesMatch>
</IfModule>
<IfModule mod_dir.c>
DirectoryIndex index.php index.html
</IfModule>

1
tests/.htaccess Normal file
View File

@@ -0,0 +1 @@
Require all denied

13
tests/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head>
<meta charset="UTF-8" />
<meta http-equiv="Refresh" content="0; url=/" />
<title>Redirection</title>
<meta name="robots" content="noindex" />
</head>
<body>
<p><a href="/">Redirection</a></p>
</body>
</html>