Compare commits
14 Commits
da90c4713c
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4fddb06060 | ||
|
|
c0b289d2bc | ||
|
|
ce18785ccb | ||
|
|
ca24f7dae7 | ||
|
|
5ca9ecfe2a | ||
|
|
4fecd838ae | ||
|
|
f35dd620aa | ||
|
|
66b472dab2 | ||
|
|
7061ef37f8 | ||
|
|
5c12a6f053 | ||
|
|
7c4f1091b4 | ||
|
|
b26ac645bd | ||
|
|
8ad6e1c81c | ||
|
|
4a759b3ff1 |
19
UPGRADING-NC.md
Normal file
19
UPGRADING-NC.md
Normal file
@@ -0,0 +1,19 @@
|
||||
DRAFT!
|
||||
|
||||
upgrade one major version at a time
|
||||
|
||||
|
||||
check that the version of postgresql is adequate for the target version before upgrading
|
||||
|
||||
if it isn't, upgrade it:
|
||||
|
||||
dump the data
|
||||
move the volume aside
|
||||
recreate the volume
|
||||
upgrade
|
||||
start
|
||||
re-import
|
||||
delete the old volume
|
||||
|
||||
copy over the pg_hba.conf, otherwise the auth credentials won't be used correctly (need:
|
||||
host all all all md5)
|
||||
@@ -4,3 +4,6 @@ roles:
|
||||
- name: mrlesmithjr.netplan
|
||||
version: v0.3.0
|
||||
|
||||
collections:
|
||||
- name: community.general
|
||||
|
||||
|
||||
16
snackpot.yml
16
snackpot.yml
@@ -12,7 +12,7 @@
|
||||
navidrome_hostname: nd.noodlefactory.co.uk
|
||||
letsencrypt_email: webmaster@noodlefactory.co.uk
|
||||
docker_compose_base_dir: /opt/docker-compose
|
||||
docker_compose_cmd: docker-compose
|
||||
docker_compose_cmd: docker compose
|
||||
borg_passphrase: "{{lookup('passwordstore', 'servers/snackpot/borg.passphrase')}}"
|
||||
smtp_password: "{{lookup('passwordstore', 'servers/snackpot/smtp.password')}}"
|
||||
borg_ssh_key: "{{lookup('passwordstore', 'servers/snackpot/borg.id_rsa')}}"
|
||||
@@ -87,7 +87,7 @@
|
||||
file:
|
||||
path: "{{ docker_compose_base_dir }}/{{ item.path }}"
|
||||
state: directory
|
||||
with_filetree: templates/docker-compose
|
||||
with_community.general.filetree: templates/docker-compose
|
||||
when: item.state == "directory" and item.path.count("/.") == 0
|
||||
tags: docker-config
|
||||
|
||||
@@ -99,8 +99,8 @@
|
||||
group: root
|
||||
mode: 0660
|
||||
backup: yes
|
||||
notify: restart docker compose services
|
||||
with_filetree: templates/docker-compose
|
||||
# notify: restart docker compose services
|
||||
with_community.general.filetree: templates/docker-compose
|
||||
when: item.state == "file" and item.path.endswith(".j2")
|
||||
tags: docker-config
|
||||
|
||||
@@ -112,8 +112,8 @@
|
||||
group: root
|
||||
mode: 0660
|
||||
backup: yes
|
||||
notify: restart docker compose services
|
||||
with_filetree: templates/docker-compose
|
||||
# notify: restart docker compose services
|
||||
with_community.general.filetree: templates/docker-compose
|
||||
when: |-
|
||||
item.state == "file" and not (
|
||||
item.path.endswith("~") or item.path.endswith(".j2")
|
||||
@@ -134,7 +134,7 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0550
|
||||
with_filetree: templates/bin
|
||||
with_community.general.filetree: templates/bin
|
||||
when: item.state == "file" and not item.path.endswith("~")
|
||||
tags: docker-config
|
||||
|
||||
@@ -149,7 +149,7 @@
|
||||
- appserver.service
|
||||
- borg.service
|
||||
- borg.timer
|
||||
tags: docker-config
|
||||
tags: docker-configz
|
||||
|
||||
- name: enable backup service
|
||||
service:
|
||||
|
||||
@@ -8,22 +8,22 @@ set -o errexit
|
||||
cd "/opt/docker-compose"
|
||||
|
||||
set -vx
|
||||
docker-compose exec -T -u www-data nextcloud ./occ maintenance:mode --on ||
|
||||
docker compose exec -T -u www-data nextcloud ./occ maintenance:mode --on ||
|
||||
echo "WARNING: Couldn't stop nextcloud container, proceeding anyway"
|
||||
docker-compose down --remove-orphans || {
|
||||
echo "ERROR: Couldn't stop docker-compose, restarting and aborting"
|
||||
docker compose down --remove-orphans || {
|
||||
echo "ERROR: Couldn't stop docker compose, restarting and aborting"
|
||||
docker network prune --force
|
||||
docker-compose up -d
|
||||
docker compose up -d
|
||||
exit
|
||||
}
|
||||
docker network prune --force # remove dangling networks
|
||||
docker-compose run --name borgmatic -T --rm borgmatic /backup.sh run ||
|
||||
docker compose run --name borgmatic -T --rm borgmatic /backup.sh run ||
|
||||
echo "ERROR: Couldn't run borgmatic"
|
||||
docker-compose up -d main-services || {
|
||||
echo "ERROR: couldn't restart docker-compose services, aborting with no services!"
|
||||
docker compose up -d main-services || {
|
||||
echo "ERROR: couldn't restart docker compose services, aborting with no services!"
|
||||
exit 1
|
||||
}
|
||||
docker-compose exec -T -u www-data nextcloud ./occ maintenance:mode --off ||
|
||||
docker compose exec -T -u www-data nextcloud ./occ maintenance:mode --off ||
|
||||
echo "Couldn't turn off nextcloud's maintainance mode"
|
||||
docker-compose run --name borgmatic -T --rm borgmatic /backup.sh check ||
|
||||
docker compose run --name borgmatic -T --rm borgmatic /backup.sh check ||
|
||||
echo "Couldn't run the bormatic backup check"
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec docker-compose run -- borgmatic borg "$@"
|
||||
exec docker compose run -- borgmatic borg "$@"
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec docker-compose run -- borgmatic borgmatic "$@"
|
||||
exec docker compose run -- borgmatic borgmatic "$@"
|
||||
|
||||
@@ -8,7 +8,7 @@ nextcloud_db_user={{ nextcloud_db_user }}
|
||||
nextcloud_db={{ nextcloud_db }}
|
||||
|
||||
DOCKER_EXE() {
|
||||
( cd $dc_dir; docker-compose exec "$@" )
|
||||
( cd $dc_dir; docker compose exec "$@" )
|
||||
}
|
||||
|
||||
ON_POSTGRES() {
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
POSTGRES_PASSWORD={{ nextcloud_db_password }}
|
||||
BORG_PASSPHRASE={{ borg_passphrase }}
|
||||
SMTP_PASSWORD={{ smtp_password }}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
FROM b3vis/borgmatic:latest-msmtp
|
||||
FROM b3vis/borgmatic:latest
|
||||
|
||||
# Install stdbuf, used by backup.sh
|
||||
RUN \
|
||||
echo "* Installing Runtime Packages" \
|
||||
&& apk upgrade --no-cache \
|
||||
&& echo "* Installing Runtime Packages" \
|
||||
&& apk add -U --no-cache \
|
||||
coreutils
|
||||
COPY --chmod=755 backup.sh /backup.sh
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Run the backup and mail the logs:
|
||||
# Depending on parameter 1:
|
||||
# - test-smtp: just send a test email to $MAIL_TO
|
||||
# - test-smtp: just send a test email using $APPRISE_URI
|
||||
# - run: create the backup, no checks
|
||||
# - check: prune, compact and check the backup
|
||||
# Anything else is an error.
|
||||
@@ -9,8 +9,6 @@
|
||||
set -o pipefail
|
||||
|
||||
# Set up environment
|
||||
/bin/sh /scripts/msmtprc.sh
|
||||
/bin/sh /scripts/env.sh
|
||||
RUN_COMMAND="borgmatic --stats -v 2 create"
|
||||
CHECK_COMMAND="borgmatic --stats -v 1 prune compact check"
|
||||
LOGFILE="/tmp/backup_run_$(date +%s).log"
|
||||
@@ -31,7 +29,7 @@ indent() {
|
||||
log() {
|
||||
# Adapted from https://stackoverflow.com/a/31151808
|
||||
{
|
||||
"$@" 2>&1 1>&3 3>&- | indent " ! "
|
||||
stdbuf -oL -eL "$@" 2>&1 1>&3 3>&- | indent " ! "
|
||||
} 3>&1 1>&2 | indent " | " | tee -a "$LOGFILE"
|
||||
}
|
||||
|
||||
@@ -43,14 +41,12 @@ report() {
|
||||
log echo "FAILED: $RESULT"
|
||||
PREFIX="$FAILED_PREFIX"
|
||||
fi
|
||||
printf "Subject: %s: '%s'\n\n%s\n" "$PREFIX" "$PARAM" "$(cat $LOGFILE)" |
|
||||
sendmail -t "$MAIL_TO"
|
||||
apprise -vv -t "$PREFIX: '$PARAM'" -b "$(cat $LOGFILE)" "$APPRISE_URI&pass=$SMTP_PASSWORD"
|
||||
log echo "Report sent."
|
||||
}
|
||||
|
||||
testmail() {
|
||||
echo -e "Subject: TESTING!\n\ntest mail, please ignore\n" |
|
||||
sendmail -t "$MAIL_TO"
|
||||
apprise -vv -t "TESTING!" -b "test mail, please ignore." "$APPRISE_URI&pass=$SMTP_PASSWORD"
|
||||
}
|
||||
|
||||
failed() {
|
||||
@@ -72,7 +68,7 @@ trap cleanup EXIT
|
||||
|
||||
case "$PARAM" in
|
||||
test-smtp)
|
||||
echo "Testing mail to $MAIL_TO"
|
||||
echo "Testing mail to via Apprise ($APPRISE_URI)"
|
||||
testmail
|
||||
echo "Done."
|
||||
;;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# Adapted from:
|
||||
# https://github.com/nextcloud/docker/blob/master/.examples/docker-compose/with-nginx-proxy/postgres/fpm/docker-compose.yml
|
||||
|
||||
version: '3'
|
||||
|
||||
volumes:
|
||||
postgres:
|
||||
@@ -56,7 +55,7 @@ services:
|
||||
- redis:/data
|
||||
|
||||
nextcloud:
|
||||
image: nextcloud:28-fpm-alpine
|
||||
image: nextcloud:31-fpm-alpine
|
||||
restart: always
|
||||
volumes:
|
||||
- nextcloud_src:/var/www/html
|
||||
@@ -76,7 +75,7 @@ services:
|
||||
# test: ["CMD-SHELL", "wget -q --spider --proxy=off localhost:3000/health || exit 1"]
|
||||
|
||||
nextcloud_cron:
|
||||
image: nextcloud:28-fpm-alpine
|
||||
image: nextcloud:31-fpm-alpine
|
||||
restart: always
|
||||
volumes:
|
||||
- nextcloud_src:/var/www/html
|
||||
@@ -261,20 +260,18 @@ services:
|
||||
- ./volumes/borg-ssh-config:/root/.ssh/ # ssh keys; sshd writes knownhosts etc here
|
||||
|
||||
environment:
|
||||
# Work around the use of a fancy init system s6:
|
||||
# https://github.com/borgmatic-collective/docker-borgmatic/issues/320#issuecomment-2089003361
|
||||
S6_KEEP_ENV: 1
|
||||
|
||||
POSTGRES_USER: nextcloud
|
||||
POSTGRES_DB: nextcloud
|
||||
POSTGRES_HOST: postgres
|
||||
BORG_ARCHIVE: nick
|
||||
BORG_ARCHIVE_LABEL: snackpot
|
||||
MAIL_RELAY_HOST: mail.noodlefactory.co.uk
|
||||
MAIL_PORT: 25
|
||||
MAIL_AUTH_METHOD: login
|
||||
MAIL_STARTTLS: 'on'
|
||||
MAIL_USER: nc.noodlefactory.co.uk
|
||||
MAIL_FROM: borgmatic@snackpot.noodlefactory.co.uk
|
||||
MAIL_TO: nick@noodlefactory.co.uk
|
||||
MAIL_SUBJECT: Borgmatic Backup
|
||||
# MAIL_PASSWORD is set via volumes/borgmatic-config/msmtp.env, created via ansible
|
||||
APPRISE_URI: "mailtos://mail.noodlefactory.co.uk:25?user=nc.noodlefactory.co.uk&from=borgmatic@snackpot.noodlefactory.co.uk&to=nick@noodlefactory.co.uk"
|
||||
# SMTP_PASSWORD is set via borgmatic.env, created via ansible,
|
||||
# and appended to APPRISE_URL by borgmatic/backup.sh script
|
||||
# Test SMTP auth on the server https://doc.dovecot.org/admin_manual/debugging/debugging_authentication/
|
||||
env_file:
|
||||
- ./borgmatic.env
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM deluan/navidrome:0.50.2
|
||||
FROM deluan/navidrome:0.55.2
|
||||
|
||||
RUN apk add --no-cache mpv
|
||||
# Ensure that navidrome has access to these directories
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
FROM postgres:11.9-alpine
|
||||
FROM postgres:17-alpine
|
||||
COPY --chown={{ postgres_db_user }}:{{ postgres_db_user }} init.sql /docker-entrypoint-initdb.d/
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM jwilder/nginx-proxy:alpine-0.7.0
|
||||
FROM jwilder/nginx-proxy:1.7-alpine
|
||||
|
||||
COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM alpine:3.19
|
||||
FROM alpine:3.21
|
||||
|
||||
RUN apk update \
|
||||
&& apk upgrade \
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
FROM nginx:1.19.6-alpine
|
||||
FROM nginx:1.28-alpine
|
||||
|
||||
COPY nginx.conf /etc/nginx/nginx.conf
|
||||
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
@@ -1,173 +1,271 @@
|
||||
worker_processes auto;
|
||||
# Adapted from https://docs.nextcloud.com/server/31/admin_manual/installation/nginx.html
|
||||
# Insert as /etc/nginx/conf.d/default.conf
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
# Set .mjs and .wasm MIME types
|
||||
# Either include it in the default mime.types list
|
||||
# and include that list explicitly or add the file extension
|
||||
# only for Nextcloud like below:
|
||||
types {
|
||||
text/javascript mjs;
|
||||
application/wasm wasm;
|
||||
}
|
||||
|
||||
upstream php-handler {
|
||||
server nextcloud:9000;
|
||||
}
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
|
||||
map $arg_v $asset_immutable {
|
||||
"" "";
|
||||
default ", immutable";
|
||||
}
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
server {
|
||||
listen 80;
|
||||
server_name nc.noodlefactory.co.uk;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
# Prevent nginx HTTP Server Detection
|
||||
server_tokens off;
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
# HSTS settings
|
||||
# WARNING: Only add the preload option once you read about
|
||||
# the consequences in https://hstspreload.org/. This option
|
||||
# will add the domain to a hardcoded list that is shipped
|
||||
# in all major browsers and getting removed from this list
|
||||
# could take several months.
|
||||
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
# Add headers to serve security related headers
|
||||
# Before enabling Strict-Transport-Security headers please read into this
|
||||
# topic first.
|
||||
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
|
||||
#
|
||||
# WARNING: Only add the preload option once you read about
|
||||
# the consequences in https://hstspreload.org/. This option
|
||||
# will add the domain to a hardcoded list that is shipped
|
||||
# in all major browsers and getting removed from this list
|
||||
# could take several months.
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Download-Options "noopen" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
keepalive_timeout 65;
|
||||
# Remove X-Powered-By, which is an information leak
|
||||
fastcgi_hide_header X-Powered-By;
|
||||
|
||||
set_real_ip_from 10.0.0.0/8;
|
||||
set_real_ip_from 172.16.0.0/12;
|
||||
set_real_ip_from 192.168.0.0/16;
|
||||
real_ip_header X-Real-IP;
|
||||
|
||||
#gzip on;
|
||||
# Path to the root of your installation
|
||||
root /var/www/html;
|
||||
|
||||
upstream php-handler {
|
||||
server nextcloud:9000;
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
# The following 2 rules are only needed for the user_webfinger app.
|
||||
# Uncomment it if you're planning to use this app.
|
||||
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
|
||||
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
|
||||
|
||||
# Add headers to serve security related headers
|
||||
# Before enabling Strict-Transport-Security headers please read into this
|
||||
# topic first.
|
||||
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
|
||||
#
|
||||
# WARNING: Only add the preload option once you read about
|
||||
# the consequences in https://hstspreload.org/. This option
|
||||
# will add the domain to a hardcoded list that is shipped
|
||||
# in all major browsers and getting removed from this list
|
||||
# could take several months.
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Download-Options "noopen" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
||||
add_header X-Robots-Tag "none" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
# The following rule is only needed for the Social app.
|
||||
# Uncomment it if you're planning to use this app.
|
||||
#rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
|
||||
|
||||
# Remove X-Powered-By, which is an information leak
|
||||
fastcgi_hide_header X-Powered-By;
|
||||
# set max upload size and increase upload timeout
|
||||
client_max_body_size 10G;
|
||||
client_body_timeout 300s;
|
||||
fastcgi_buffers 64 4K;
|
||||
|
||||
# Path to the root of your installation
|
||||
root /var/www/html;
|
||||
# The settings allows you to optimize the HTTP2 bandwidth.
|
||||
# See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
|
||||
# for tuning hints
|
||||
client_body_buffer_size 512k;
|
||||
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
# Enable gzip but do not remove ETag headers
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_comp_level 4;
|
||||
gzip_min_length 256;
|
||||
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
|
||||
gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
|
||||
|
||||
# The following 2 rules are only needed for the user_webfinger app.
|
||||
# Uncomment it if you're planning to use this app.
|
||||
#rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
|
||||
#rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
|
||||
# Pagespeed is not supported by Nextcloud, so if your server is built
|
||||
# with the `ngx_pagespeed` module, uncomment this line to disable it.
|
||||
#pagespeed off;
|
||||
|
||||
# The following rule is only needed for the Social app.
|
||||
# Uncomment it if you're planning to use this app.
|
||||
#rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
|
||||
|
||||
location = /.well-known/carddav {
|
||||
return 301 $scheme://$host:$server_port/remote.php/dav;
|
||||
}
|
||||
# Specify how to handle directories -- specifying `/index.php$request_uri`
|
||||
# here as the fallback means that Nginx always exhibits the desired behaviour
|
||||
# when a client requests a path that corresponds to a directory that exists
|
||||
# on the server. In particular, if that directory contains an index.php file,
|
||||
# that file is correctly served; if it doesn't, then the request is passed to
|
||||
# the front-end controller. This consistent behaviour means that we don't need
|
||||
# to specify custom rules for certain paths (e.g. images and other assets,
|
||||
# `/updater`, `/ocs-provider`), and thus
|
||||
# `try_files $uri $uri/ /index.php$request_uri`
|
||||
# always provides the desired behaviour.
|
||||
index index.php index.html /index.php$request_uri;
|
||||
|
||||
location = /.well-known/caldav {
|
||||
return 301 $scheme://$host:$server_port/remote.php/dav;
|
||||
}
|
||||
|
||||
# set max upload size
|
||||
client_max_body_size 10G;
|
||||
fastcgi_buffers 64 4K;
|
||||
|
||||
# Enable gzip but do not remove ETag headers
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_comp_level 4;
|
||||
gzip_min_length 256;
|
||||
gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
|
||||
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;
|
||||
|
||||
# Uncomment if your server is build with the ngx_pagespeed module
|
||||
# This module is currently not supported.
|
||||
#pagespeed off;
|
||||
|
||||
location / {
|
||||
rewrite ^ /index.php;
|
||||
}
|
||||
|
||||
location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
|
||||
deny all;
|
||||
}
|
||||
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
|
||||
set $path_info $fastcgi_path_info;
|
||||
try_files $fastcgi_script_name =404;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $path_info;
|
||||
# fastcgi_param HTTPS on;
|
||||
|
||||
# Avoid sending the security headers twice
|
||||
fastcgi_param modHeadersAvailable true;
|
||||
|
||||
# Enable pretty urls
|
||||
fastcgi_param front_controller_active true;
|
||||
fastcgi_pass php-handler;
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_request_buffering off;
|
||||
}
|
||||
|
||||
location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
|
||||
try_files $uri/ =404;
|
||||
index index.php;
|
||||
}
|
||||
|
||||
# Adding the cache control header for js, css and map files
|
||||
# Make sure it is BELOW the PHP block
|
||||
location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
|
||||
try_files $uri /index.php$request_uri;
|
||||
add_header Cache-Control "public, max-age=15778463";
|
||||
# Add headers to serve security related headers (It is intended to
|
||||
# have those duplicated to the ones above)
|
||||
# Before enabling Strict-Transport-Security headers please read into
|
||||
# this topic first.
|
||||
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
|
||||
#
|
||||
# WARNING: Only add the preload option once you read about
|
||||
# the consequences in https://hstspreload.org/. This option
|
||||
# will add the domain to a hardcoded list that is shipped
|
||||
# in all major browsers and getting removed from this list
|
||||
# could take several months.
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Download-Options "noopen" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
||||
add_header X-Robots-Tag "none" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# Optional: Don't log access to assets
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
|
||||
try_files $uri /index.php$request_uri;
|
||||
# Optional: Don't log access to other assets
|
||||
access_log off;
|
||||
}
|
||||
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
|
||||
location = / {
|
||||
if ( $http_user_agent ~ ^DavClnt ) {
|
||||
return 302 /remote.php/webdav/$is_args$args;
|
||||
}
|
||||
}
|
||||
|
||||
# Make a regex exception for `/.well-known` so that clients can still
|
||||
# access it despite the existence of the regex rule
|
||||
# `location ~ /(\.|autotest|...)` which would otherwise handle requests
|
||||
# for `/.well-known`.
|
||||
location ^~ /.well-known {
|
||||
# The rules in this block are an adaptation of the rules
|
||||
# in `.htaccess` that concern `/.well-known`.
|
||||
|
||||
location = /.well-known/carddav { return 301 /remote.php/dav/; }
|
||||
location = /.well-known/caldav { return 301 /remote.php/dav/; }
|
||||
|
||||
location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
|
||||
location /.well-known/pki-validation { try_files $uri $uri/ =404; }
|
||||
|
||||
# Let Nextcloud's API for `/.well-known` URIs handle all other
|
||||
# requests by passing them to the front-end controller.
|
||||
return 301 /index.php$request_uri;
|
||||
}
|
||||
|
||||
# Rules borrowed from `.htaccess` to hide certain paths from clients
|
||||
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
|
||||
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
|
||||
|
||||
# Ensure this block, which passes PHP files to the PHP process, is above the blocks
|
||||
# which handle static assets (as seen below). If this block is not declared first,
|
||||
# then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
|
||||
# to the URI, resulting in a HTTP 500 error response.
|
||||
location ~ \.php(?:$|/) {
|
||||
# Required for legacy support
|
||||
rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;
|
||||
|
||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||
set $path_info $fastcgi_path_info;
|
||||
|
||||
try_files $fastcgi_script_name =404;
|
||||
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param PATH_INFO $path_info;
|
||||
fastcgi_param HTTPS on;
|
||||
|
||||
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
|
||||
fastcgi_param front_controller_active true; # Enable pretty urls
|
||||
fastcgi_pass php-handler;
|
||||
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_request_buffering off;
|
||||
|
||||
fastcgi_max_temp_file_size 0;
|
||||
}
|
||||
|
||||
# Serve static files
|
||||
location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac)$ {
|
||||
try_files $uri /index.php$request_uri;
|
||||
# HTTP response headers borrowed from Nextcloud `.htaccess`
|
||||
add_header Cache-Control "public, max-age=15778463$asset_immutable";
|
||||
add_header Referrer-Policy "no-referrer" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Permitted-Cross-Domain-Policies "none" always;
|
||||
add_header X-Robots-Tag "noindex, nofollow" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
access_log off; # Optional: Don't log access to assets
|
||||
}
|
||||
|
||||
location ~ \.(otf|woff2?)$ {
|
||||
try_files $uri /index.php$request_uri;
|
||||
expires 7d; # Cache-Control policy borrowed from `.htaccess`
|
||||
access_log off; # Optional: Don't log access to assets
|
||||
}
|
||||
|
||||
# Rule borrowed from `.htaccess`
|
||||
location /remote {
|
||||
return 301 /remote.php$request_uri;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php$request_uri;
|
||||
}
|
||||
##
|
||||
## location / {
|
||||
## rewrite ^ /index.php;
|
||||
## }
|
||||
##
|
||||
## location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
|
||||
## deny all;
|
||||
## }
|
||||
## location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
|
||||
## deny all;
|
||||
## }
|
||||
##
|
||||
## location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
|
||||
## fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
|
||||
## set $path_info $fastcgi_path_info;
|
||||
## try_files $fastcgi_script_name =404;
|
||||
## include fastcgi_params;
|
||||
## fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
## fastcgi_param PATH_INFO $path_info;
|
||||
## # fastcgi_param HTTPS on;
|
||||
##
|
||||
## # Avoid sending the security headers twice
|
||||
## fastcgi_param modHeadersAvailable true;
|
||||
##
|
||||
## # Enable pretty urls
|
||||
## fastcgi_param front_controller_active true;
|
||||
## fastcgi_pass php-handler;
|
||||
## fastcgi_intercept_errors on;
|
||||
## fastcgi_request_buffering off;
|
||||
## }
|
||||
##
|
||||
## location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
|
||||
## try_files $uri/ =404;
|
||||
## index index.php;
|
||||
## }
|
||||
##
|
||||
## # Adding the cache control header for js, css and map files
|
||||
## # Make sure it is BELOW the PHP block
|
||||
## location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
|
||||
## try_files $uri /index.php$request_uri;
|
||||
## add_header Cache-Control "public, max-age=15778463";
|
||||
## # Add headers to serve security related headers (It is intended to
|
||||
## # have those duplicated to the ones above)
|
||||
## # Before enabling Strict-Transport-Security headers please read into
|
||||
## # this topic first.
|
||||
## #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
|
||||
## #
|
||||
## # WARNING: Only add the preload option once you read about
|
||||
## # the consequences in https://hstspreload.org/. This option
|
||||
## # will add the domain to a hardcoded list that is shipped
|
||||
## # in all major browsers and getting removed from this list
|
||||
## # could take several months.
|
||||
## add_header Referrer-Policy "no-referrer" always;
|
||||
## add_header X-Content-Type-Options "nosniff" always;
|
||||
## add_header X-Download-Options "noopen" always;
|
||||
## add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
## add_header X-Permitted-Cross-Domain-Policies "none" always;
|
||||
## add_header X-Robots-Tag "none" always;
|
||||
## add_header X-XSS-Protection "1; mode=block" always;
|
||||
##
|
||||
## # Optional: Don't log access to assets
|
||||
## access_log off;
|
||||
## }
|
||||
##
|
||||
## location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
|
||||
## try_files $uri /index.php$request_uri;
|
||||
## # Optional: Don't log access to other assets
|
||||
## access_log off;
|
||||
## }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user