paheko_docker_image_builder/000-default.conf

144 lines
5 KiB
Text
Raw Normal View History

2023-10-06 15:39:40 +02:00
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/paheko/www
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
# Following is from : https://fossil.kd2.org/paheko/file?name=src/apache-vhost.conf
Options -Indexes -Multiviews +FollowSymlinks
DirectoryIndex index.php index.html
# Some security
<IfModule mod_alias.c>
RedirectMatch 404 _inc\.php
</IfModule>
# Recommended, if you have xsendfile module
# see https://tn123.org/mod_xsendfile/
# Also enable X-SendFile in config.local.php
#
#<IfModule mod_xsendfile.c>
# <Files *.php>
# XSendFile On
# XSendFilePath /home/paheko/
# </Files>
#</IfModule>
# This is to avoid caching mismatch when using mod_deflate
# see https://github.com/symfony/symfony-docs/issues/12644
<IfModule mod_deflate.c>
FileETag None
</IfModule>
# Allow uploads up to 256 MB where it's required
<If "%{REQUEST_URI} =~ m!^/admin/(?:common/files|config/backup)/|^/(?:web)?dav/|^/remote\.php/(?:web)?dav/! && -n %{HTTP_COOKIE}">
<IfModule mod_php.c>
php_value post_max_size 256M
php_value upload_max_filesize 256M
</IfModule>
<IfModule mod_php7.c>
php_value post_max_size 256M
php_value upload_max_filesize 256M
</IfModule>
<IfModule !mod_php.c>
<IfModule !mod_php7.c>
SetEnv PHP_VALUE "post_max_size=256M"
# There is no way to pass multiple PHP ini settings via PHP_VALUE :-(
# so we use PHP_ADMIN_VALUE here. It works unless we have more than 2 settings to change.
SetEnv PHP_ADMIN_VALUE "upload_max_filesize=256M"
</IfModule>
</IfModule>
</If>
<IfModule mod_rewrite.c>
AddDefaultCharset utf-8
AddCharset utf-8 .html .css .js .txt
RewriteEngine On
#RewriteBase /
RewriteRule \.cache - [R=404]
RewriteRule \.well-known/assetlinks.json - [R=404]
# Stop rewrite for /admin URL, except for /admin/p/ (plugins)
RewriteCond %{REQUEST_URI} ^/?admin(?!/p/)
RewriteRule ^ - [END]
# Skip directly to router if possible
# Do not try cache if method is not GET or HEAD
RewriteCond %{REQUEST_METHOD} !GET|HEAD [OR]
# Do not try to get from cache if URL is private, or belongs to modules/plugins
RewriteCond %{REQUEST_URI} ^/admin|^/?(?:dav|wopi|p|m|api)/|\.php$ [OR]
# NextCloud routes
RewriteCond %{REQUEST_URI} ^/?(?:remote\.php|index\.php|ocs|avatars|status\.php)/ [OR]
# Private files are not part of the cache
RewriteCond %{REQUEST_URI} ^/?(?:documents|user|transaction|ext|attachments|versions)/
# Skip, go to router directly
RewriteRule ^ - [skip=8]
# Store MD5 hashes in environment variables
RewriteCond %{REQUEST_URI} ^(.+)(?:\?|$)
RewriteRule ^ "-" [E=CACHE_URI:%1]
# Extract file extension (required for Apache to serve the correct mimetype)
RewriteCond %{REQUEST_URI} (\.[a-z0-9]+)(?:\?|$)
RewriteRule ^ "-" [E=CACHE_EXT:%1]
# If no extension, default to .html
RewriteCond %{REQUEST_URI} !\.[a-z0-9]+(?:\?|$)
RewriteRule ^ "-" [E=CACHE_EXT:.html]
RewriteCond expr "md5(%{ENV:CACHE_URI}) =~ /^(.+)$/"
RewriteRule ^ "-" [E=CACHE_URI_MD5:%1]
RewriteCond expr "md5(tolower(%{HTTP_HOST})) =~ /^((.{2}).+)$/"
RewriteRule ^ "-" [E=CACHE_HOST_MD5:%1,E=CACHE_HOST2_MD5:%2]
RewriteCond /.cache/%{ENV:CACHE_HOST_MD5}/%{ENV:CACHE_URI_MD5} (.+)
RewriteRule ^ "-" [E=CACHE_PATH:%1]
# Serve symlinks for files
RewriteCond %{QUERY_STRING} ="" [OR]
RewriteCond %{QUERY_STRING} ^h=[a-f0-9]+$
RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} -l
RewriteRule ^ %{ENV:CACHE_PATH}%{ENV:CACHE_EXT} [END]
# Do not try cache for pages if user is logged-in
RewriteCond %{HTTP_COOKIE} !pko=
# Serve static HTML pages
RewriteCond %{QUERY_STRING} =""
RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} -f
RewriteCond %{DOCUMENT_ROOT}%{ENV:CACHE_PATH}%{ENV:CACHE_EXT} !-l
RewriteRule ^ %{ENV:CACHE_PATH}%{ENV:CACHE_EXT} [END]
# Redirect to router
RewriteRule ^ /_route.php [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},END,QSA]
</IfModule>
</VirtualHost>