== Neater URLs ==
Add this line to `$NEXTDIR/config/config.php`:
{{{
cd $NEXTDIR
php7.2 occ config:system:set htaccess.RewriteBase --type=string --value="/"
php7.2 occ maintenance:update:htaccess
}}}
The second command should not be necessary, but it will generate a correct `.htaccess` for your version, for Nextcloud 15 it will look like this:
{{{
SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
# Add security and privacy related headers
Header set X-Content-Type-Options "nosniff"
Header set X-XSS-Protection "1; mode=block"
Header set X-Robots-Tag "none"
Header set X-Download-Options "noopen"
Header set X-Permitted-Cross-Domain-Policies "none"
Header set Referrer-Policy "no-referrer"
SetEnv modHeadersAvailable true
# Add cache control for static resources
Header set Cache-Control "max-age=15778463"
# Let browsers cache WOFF files for a week
Header set Cache-Control "max-age=604800"
php_value upload_max_filesize 511M
php_value post_max_size 511M
php_value memory_limit 512M
php_value mbstring.func_overload 0
php_value always_populate_raw_post_data -1
php_value default_charset 'UTF-8'
php_value output_buffering 0
SetEnv htaccessWorking true
php_value upload_max_filesize 511M
php_value post_max_size 511M
php_value memory_limit 512M
php_value mbstring.func_overload 0
php_value default_charset 'UTF-8'
php_value output_buffering 0
SetEnv htaccessWorking true
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} DavClnt
RewriteRule ^$ /remote.php/webdav/ [L,R=302]
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^\.well-known/host-meta /public.php?service=host-meta [QSA,L]
RewriteRule ^\.well-known/host-meta\.json /public.php?service=host-meta-json [QSA,L]
RewriteRule ^\.well-known/webfinger /public.php?service=webfinger [QSA,L]
RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
RewriteRule ^remote/(.*) remote.php [QSA,L]
RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
RewriteRule ^(?:\.|autotest|occ|issue|indie|db_|console).* - [R=404,L]
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
DirectoryIndex index.php index.html
AddDefaultCharset utf-8
Options -Indexes
ModPagespeed Off
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####
ErrorDocument 403 /
ErrorDocument 404 /
Options -MultiViews
RewriteRule ^core/js/oc.js$ index.php [PT,E=PATH_INFO:$1]
RewriteRule ^core/preview.png$ index.php [PT,E=PATH_INFO:$1]
RewriteCond %{REQUEST_FILENAME} !\.(css|js|svg|gif|png|html|ttf|woff2?|ico|jpg|jpeg)$
RewriteCond %{REQUEST_FILENAME} !core/img/favicon.ico$
RewriteCond %{REQUEST_FILENAME} !core/img/manifest.json$
RewriteCond %{REQUEST_FILENAME} !/remote.php
RewriteCond %{REQUEST_FILENAME} !/public.php
RewriteCond %{REQUEST_FILENAME} !/cron.php
RewriteCond %{REQUEST_FILENAME} !/core/ajax/update.php
RewriteCond %{REQUEST_FILENAME} !/status.php
RewriteCond %{REQUEST_FILENAME} !/ocs/v1.php
RewriteCond %{REQUEST_FILENAME} !/ocs/v2.php
RewriteCond %{REQUEST_FILENAME} !/robots.txt
RewriteCond %{REQUEST_FILENAME} !/updater/
RewriteCond %{REQUEST_FILENAME} !/ocs-provider/
RewriteCond %{REQUEST_URI} !^/\.well-known/(acme-challenge|pki-validation)/.*
RewriteRule . index.php [PT,E=PATH_INFO:$1]
RewriteBase /
SetEnv front_controller_active true
DirectorySlash off
}}}
If someone can get this working to remove the 'index.php' stuff from URLs, please update the configuration on the main page.
Here is my best attempt so far:
{{{
web "cloud" where
PhpVersion = php72;
DocumentRoot = home "www/cloud.elektrubadur.se";
SSL = elektrubadurCertificate;
with
expiresByType "text/css" access 1 weeks;
expiresByType "application/javascript" access 1 weeks;
expiresByType "image/svg" access 1 weeks;
expiresByType "image/gif" access 1 weeks;
expiresByType "application/font-woff2" access 1 weeks;
setEnv "front_controller_active" "true";
setEnv "htaccessWorking" "true";
setEnvIfNoCase "^Authorization$" "(.+)" ["XAUTHORIZATION=$1"];
location "/" with
unset_options [indexes, multiViews];
directoryIndex ["index.php", "index.html"];
errorDocument "403" "/";
errorDocument "404" "/";
end;
rewriteCond "%{HTTP_USER_AGENT}" "DavClnt" [];
rewriteRule "^$" "/remote.php/webdav/" [redirectWith temp, last];
rewriteRule ".*" "-" [env "HTTP_AUTHORIZATION" "%{HTTP:Authorization}"];
rewriteRule "^\.well-known/host-meta" "/public.php?service=host-meta" [qsappend, last];
rewriteRule "^\.well-known/host-meta\.json" "/public.php?service=host-meta-json" [qsappend, last];
rewriteRule "^\.well-known/webfinger" "/public.php?service=webfinger" [qsappend, last];
rewriteRule "^\.well-known/carddav" "/remote.php/dav/" [redirectWith permanent, last];
rewriteRule "^\.well-known/caldav" "/remote.php/dav/" [redirectWith permanent, last];
rewriteRule "^remote/(.*)" "remote.php" [qsappend, last];
rewriteRule "^(?:build|tests|config|lib|3rdparty|templates)/.*" "-" [redirectWith notfound, last];
rewriteCond "%{REQUEST_URI}" "!^/\.well-known/(acme-challenge|pki-validation)/.*" [];
rewriteRule "^(?:\.|autotest|occ|issue|indie|db_|console).*" "-" [redirectWith notfound, last];
directory elektrubadurRoot with
rewriteRule "^core/js/oc.js$" "index.php" [passthrough, env "PATH_INFO" "$1"];
rewriteRule "^core/preview.png$" "index.php" [passthrough, env "PATH_INFO" "$1"];
rewriteCond "%{REQUEST_FILENAME}" "!\.(css|js|svg|gif|png|html|ttf|woff2?|ico|jpg|jpeg)$" [];
rewriteCond "%{REQUEST_FILENAME}" "!core/img/favicon.ico$" [];
rewriteCond "%{REQUEST_FILENAME}" "!core/img/manifest.json$" [];
rewriteCond "%{REQUEST_FILENAME}" "!/remote.php" [];
rewriteCond "%{REQUEST_FILENAME}" "!/public.php" [];
rewriteCond "%{REQUEST_FILENAME}" "!/cron.php" [];
rewriteCond "%{REQUEST_FILENAME}" "!/core/ajax/update.php" [];
rewriteCond "%{REQUEST_FILENAME}" "!/status.php" [];
rewriteCond "%{REQUEST_FILENAME}" "!/ocs/v1.php" [];
rewriteCond "%{REQUEST_FILENAME}" "!/ocs/v2.php" [];
rewriteCond "%{REQUEST_FILENAME}" "!/robots.txt" [];
rewriteCond "%{REQUEST_FILENAME}" "!/updater/" [];
rewriteCond "%{REQUEST_FILENAME}" "!/ocs-provider/" [];
rewriteCond "%{REQUEST_URI}" "!^/\.well-known/(acme-challenge|pki-validation)/.*" [];
rewriteRule "." "index.php" [passthrough, env "PATH_INFO" "$1"];
rewriteBase "/";
end;
web "cloud" with
rewriteRule "^(.*)$" "https://cloud.elektrubadur.se$1" [redirectWith permanent];
end;
}}}
=== Drop unused tables ==
We should drop those deprecated tables from before, this wasn't actually working for me.
{{{
mysql-fixperms
mysql -h mysql -p ${USER}_cloud
DROP TABLE admin_sections;
DROP TABLE admin_settings);
DROP TABLE personal_sections;
DROP TABLE 'personal_settings;
}}}
=== Running Updates ===
Here is '''incomplete, work-in-progress''' script by StephenMichel for automating updates, provided without context or further explanation :P
{{{
#! the wiki eats this line for some reason, it's not part of the script
#!/usr/bin/env bash
# set -x
set -eu -o pipefail
nextcloud_dir="$HOME/vhosts/nextcloud.smichel.me"
v_new="19.0.8"
v_cur="$(ls "$nextcloud_dir"/config-*.php | sort | tail -n 1 | xargs basename \
| sed -e '
s/^config-//
s/\.php$//
')"
echo cur: $v_cur
echo new: $v_new
usage() {
cat <