Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[enh] deny dotfiles in Apache2 with PHP conf in Vhost #16

Open
wants to merge 2 commits into
base: 3.5-octopuce
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@

build:

build_deb:
dpkg-buildpackage -us -uc

install:
install -m 0644 -o root -g root apache2/* $(DESTDIR)/etc/alternc/templates/apache2/
install -m 0644 -o root -g root php/* $(DESTDIR)/etc/alternc/templates/php/
Expand Down
24 changes: 23 additions & 1 deletion apache2/php56-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@
AssignUserId #%%UID%% #%%GID%%
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1


# Custom extentions
<FilesMatch ^.*(log|sql|sqlite|bak|swp|php~)$>
Order allow,deny
Deny from all
</FilesMatch>

# Common folders to deny
<DirectoryMatch .*\.(svn|git|ssh)/.*>
Order allow,deny
Deny from all
</DirectoryMatch>

# Common files or folder names begin by
<FilesMatch .*\.(user.ini|php.ini|ssh|env|hg|gitignore|bashrc|bash_history|zsh_history|mysql_history|ht)$>
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch (user.ini|php.ini)$>
Order allow,deny
Deny from all
</FilesMatch>

<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php5.6-%%LOGIN%%.sock|fcgi://localhost"
</FilesMatch>
Expand Down
24 changes: 23 additions & 1 deletion apache2/php70-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@
AssignUserId #%%UID%% #%%GID%%
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1


# Custom extentions
<FilesMatch ^.*(log|sql|sqlite|bak|swp|php~)$>
Order allow,deny
Deny from all
</FilesMatch>

# Common folders to deny
<DirectoryMatch .*\.(svn|git|ssh)/.*>
Order allow,deny
Deny from all
</DirectoryMatch>

# Common files or folder names begin by
<FilesMatch .*\.(user.ini|php.ini|ssh|env|hg|gitignore|bashrc|bash_history|zsh_history|mysql_history|ht)$>
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch (user.ini|php.ini)$>
Order allow,deny
Deny from all
</FilesMatch>

<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.0-%%LOGIN%%.sock|fcgi://localhost"
</FilesMatch>
Expand Down
22 changes: 22 additions & 0 deletions apache2/php71-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

# Custom extentions
<FilesMatch ^.*(log|sql|sqlite|bak|swp|php~)$>
Order allow,deny
Deny from all
</FilesMatch>

# Common folders to deny
<DirectoryMatch .*\.(svn|git|ssh)/.*>
Order allow,deny
Deny from all
</DirectoryMatch>

# Common files or folder names begin by
<FilesMatch .*\.(user.ini|php.ini|ssh|env|hg|gitignore|bashrc|bash_history|zsh_history|mysql_history|ht)$>
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch (user.ini|php.ini)$>
Order allow,deny
Deny from all
</FilesMatch>

<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.1-%%LOGIN%%.sock|fcgi://localhost"
</FilesMatch>
Expand Down
24 changes: 23 additions & 1 deletion apache2/php72-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@
AssignUserId #%%UID%% #%%GID%%
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1


# Custom extentions
<FilesMatch ^.*(log|sql|sqlite|bak|swp|php~)$>
Order allow,deny
Deny from all
</FilesMatch>

# Common folders to deny
<DirectoryMatch .*\.(svn|git|ssh)/.*>
Order allow,deny
Deny from all
</DirectoryMatch>

# Common files or folder names begin by
<FilesMatch .*\.(user.ini|php.ini|ssh|env|hg|gitignore|bashrc|bash_history|zsh_history|mysql_history|ht)$>
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch (user.ini|php.ini)$>
Order allow,deny
Deny from all
</FilesMatch>

<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.2-%%LOGIN%%.sock|fcgi://localhost"
</FilesMatch>
Expand Down
22 changes: 22 additions & 0 deletions apache2/php73-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

# Custom extentions
<FilesMatch ^.*(log|sql|sqlite|bak|swp|php~)$>
Order allow,deny
Deny from all
</FilesMatch>

# Common folders to deny
<DirectoryMatch .*\.(svn|git|ssh)/.*>
Order allow,deny
Deny from all
</DirectoryMatch>

# Common files or folder names begin by
<FilesMatch .*\.(user.ini|php.ini|ssh|env|hg|gitignore|bashrc|bash_history|zsh_history|mysql_history|ht)$>
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch (user.ini|php.ini)$>
Order allow,deny
Deny from all
</FilesMatch>

<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.3-%%LOGIN%%.sock|fcgi://localhost"
</FilesMatch>
Expand Down
24 changes: 23 additions & 1 deletion apache2/php74-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,29 @@
AssignUserId #%%UID%% #%%GID%%
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1


# Custom extentions
<FilesMatch ^.*(log|sql|sqlite|bak|swp|php~)$>
Order allow,deny
Deny from all
</FilesMatch>

# Common folders to deny
<DirectoryMatch .*\.(svn|git|ssh)/.*>
Order allow,deny
Deny from all
</DirectoryMatch>

# Common files or folder names begin by
<FilesMatch .*\.(user.ini|php.ini|ssh|env|hg|gitignore|bashrc|bash_history|zsh_history|mysql_history|ht)$>
Order allow,deny
Deny from all
</FilesMatch>
<FilesMatch (user.ini|php.ini)$>
Order allow,deny
Deny from all
</FilesMatch>

<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.4-%%LOGIN%%.sock|fcgi://localhost"
</FilesMatch>
Expand Down
1 change: 1 addition & 0 deletions apache2/php80-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1


<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.0-%%LOGIN%%.sock|fcgi://localhost"
</FilesMatch>
Expand Down
3 changes: 2 additions & 1 deletion apache2/php81-fpm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
AssignUserId #%%UID%% #%%GID%%
SetEnv LOGIN "%%UID%%-%%LOGIN%%"
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1



<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.1-%%LOGIN%%.sock|fcgi://localhost"
</FilesMatch>
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
alternc-php-fpm (3.5.1~octopuce) oldstable; urgency=low

* Add rule to ignore dotfile in Apache2/PHP-fpm vhost templates

-- Pierre Bourdin <pierre@octopuce.fr> Wed, 31 Aug 2022 17:08:04 +0200

alternc-php-fpm (3.5~octopuce) oldstable; urgency=low

* Add php8.{0,1} handling
Expand Down