update
This commit is contained in:
parent
3f85e11fb8
commit
446af7bf74
|
@ -22,6 +22,9 @@ http {
|
|||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
# Prevent nginx HTTP Server Detection
|
||||
server_tokens off;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
#gzip on;
|
||||
|
@ -33,55 +36,16 @@ http {
|
|||
server {
|
||||
listen 80;
|
||||
|
||||
# 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;
|
||||
#
|
||||
# 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 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;
|
||||
|
||||
# Remove X-Powered-By, which is an information leak
|
||||
fastcgi_hide_header X-Powered-By;
|
||||
|
||||
# Path to the root of your installation
|
||||
root /var/www/html;
|
||||
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# 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;
|
||||
|
||||
# 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;
|
||||
}
|
||||
|
||||
location = /.well-known/caldav {
|
||||
return 301 $scheme://$host:$server_port/remote.php/dav;
|
||||
}
|
||||
#add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
|
||||
|
||||
# set max upload size
|
||||
client_max_body_size 10G;
|
||||
client_max_body_size 512M;
|
||||
fastcgi_buffers 64 4K;
|
||||
|
||||
# Enable gzip but do not remove ETag headers
|
||||
|
@ -92,77 +56,118 @@ http {
|
|||
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 is not supported by Nextcloud, so if your server is built
|
||||
# with the `ngx_pagespeed` module, uncomment this line to disable it.
|
||||
#pagespeed off;
|
||||
|
||||
location / {
|
||||
rewrite ^ /index.php;
|
||||
# HTTP response headers borrowed from Nextcloud `.htaccess`
|
||||
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;
|
||||
|
||||
# Remove X-Powered-By, which is an information leak
|
||||
fastcgi_hide_header X-Powered-By;
|
||||
|
||||
# Path to the root of your installation
|
||||
root /var/www/html;
|
||||
|
||||
# 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`, `/ocm-provider`, `/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;
|
||||
|
||||
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
|
||||
location = / {
|
||||
if ( $http_user_agent ~ ^DavClnt ) {
|
||||
return 302 /remote.php/webdav/$is_args$args;
|
||||
}
|
||||
}
|
||||
|
||||
location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
|
||||
deny all;
|
||||
}
|
||||
location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
|
||||
deny all;
|
||||
location = /robots.txt {
|
||||
allow all;
|
||||
log_not_found off;
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) {
|
||||
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
|
||||
# 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\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/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 HTTPS on;
|
||||
|
||||
# Avoid sending the security headers twice
|
||||
fastcgi_param modHeadersAvailable true;
|
||||
|
||||
# Enable pretty urls
|
||||
fastcgi_param front_controller_active true;
|
||||
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;
|
||||
}
|
||||
|
||||
location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
|
||||
try_files $uri/ =404;
|
||||
index index.php;
|
||||
location ~ \.(?:css|js|svg|gif)$ {
|
||||
try_files $uri /index.php$request_uri;
|
||||
expires 6M; # Cache-Control policy borrowed from `.htaccess`
|
||||
access_log off; # Optional: Don't log access to assets
|
||||
}
|
||||
|
||||
# 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)$ {
|
||||
location ~ \.woff2?$ {
|
||||
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;
|
||||
expires 7d; # Cache-Control policy borrowed from `.htaccess`
|
||||
access_log off; # Optional: Don't log access to assets
|
||||
}
|
||||
|
||||
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`
|
||||
location /remote {
|
||||
return 301 /remote.php$request_uri;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php$request_uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,20 +34,20 @@ and for [memory file caching](https://docs.nextcloud.com/server/latest/admin_man
|
|||
└── ~/
|
||||
└── docker/
|
||||
└── nextcloud/
|
||||
├── nextcloud-data/
|
||||
├── nextcloud-db-data/
|
||||
├── .env
|
||||
├── docker-compose.yml
|
||||
├── nginx.conf
|
||||
└── nextcloud-backup-script.sh
|
||||
├── 🗁 nextcloud-data/
|
||||
├── 🗁 nextcloud-db-data/
|
||||
├── 🗋 .env
|
||||
├── 🗋 docker-compose.yml
|
||||
├── 🗋 nginx.conf
|
||||
└── 🗋 nextcloud-backup-script.sh
|
||||
```
|
||||
|
||||
* `nextcloud-data/` - a directory where nextcloud will store users data and web app data
|
||||
* `nextcloud-db-data/` - a directory where nextcloud will store its database data
|
||||
* `nextcloud-data/` - users data and web app data
|
||||
* `nextcloud-db-data/` - database data
|
||||
* `.env` - a file containing environment variables for docker compose
|
||||
* `docker-compose.yml` - a docker compose file, telling docker how to run the containers
|
||||
* `nginx.conf` - nginx web server configuration file
|
||||
* `nextcloud-backup-script.sh` - a backup script if you want it
|
||||
* `nextcloud-backup-script.sh` - a backup script, to be run daily
|
||||
|
||||
You only need to provide the files.</br>
|
||||
The directories are created by docker compose on the first run.
|
||||
|
@ -79,10 +79,10 @@ services:
|
|||
restart: unless-stopped
|
||||
env_file: .env
|
||||
volumes:
|
||||
- ./nextcloud-data-db:/var/lib/mysql
|
||||
- ./nextcloud_data_db:/var/lib/mysql
|
||||
|
||||
nextcloud-redis:
|
||||
image: redis:5.0.9-alpine
|
||||
image: redis:alpine
|
||||
container_name: nextcloud-redis
|
||||
hostname: nextcloud-redis
|
||||
restart: unless-stopped
|
||||
|
@ -97,7 +97,7 @@ services:
|
|||
- nextcloud-db
|
||||
- nextcloud-redis
|
||||
volumes:
|
||||
- ./nextcloud-data/:/var/www/html
|
||||
- ./nextcloud_data/:/var/www/html
|
||||
|
||||
nextcloud-web:
|
||||
image: nginx:alpine
|
||||
|
@ -105,8 +105,10 @@ services:
|
|||
hostname: nextcloud-web
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./nextcloud-data/:/var/www/html:ro
|
||||
- ./nextcloud_data/:/var/www/html:ro
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf:ro
|
||||
expose:
|
||||
- 80:80
|
||||
|
||||
nextcloud-cron:
|
||||
image: nextcloud:fpm-alpine
|
||||
|
@ -114,7 +116,7 @@ services:
|
|||
hostname: nextcloud-cron
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./nextcloud-data/:/var/www/html
|
||||
- ./nextcloud_data/:/var/www/html
|
||||
entrypoint: /cron.sh
|
||||
depends_on:
|
||||
- nextcloud-db
|
||||
|
@ -122,42 +124,45 @@ services:
|
|||
|
||||
networks:
|
||||
default:
|
||||
external:
|
||||
name: $DOCKER_MY_NETWORK
|
||||
name: $DOCKER_MY_NETWORK
|
||||
external: true
|
||||
```
|
||||
|
||||
`.env`
|
||||
```bash
|
||||
# GENERAL
|
||||
MY_DOMAIN=example.com
|
||||
DOCKER_MY_NETWORK=caddy_net
|
||||
TZ=Europe/Bratislava
|
||||
|
||||
# NEXTCLOUD-MARIADB
|
||||
MYSQL_ROOT_PASSWORD=nextcloud
|
||||
MARIADB_AUTO_UPGRADE=1
|
||||
MARIADB_DISABLE_UPGRADE_BACKUP=1
|
||||
MYSQL_PASSWORD=nextcloud
|
||||
MYSQL_DATABASE=nextcloud
|
||||
MYSQL_USER=nextcloud
|
||||
|
||||
# NEXTCLOUD
|
||||
# NEXTCLOUD-APP
|
||||
MYSQL_HOST=nextcloud-db
|
||||
REDIS_HOST=nextcloud-redis
|
||||
OVERWRITEPROTOCOL=https
|
||||
TRUSTED_PROXIES=caddy
|
||||
NC_default_phone_region=SK # CHANGE TO YOUR COUNTRY CODE
|
||||
|
||||
# USING SENDGRID FOR SENDING EMAILS
|
||||
# USING SENDINBLUE FOR SENDING EMAILS
|
||||
MAIL_DOMAIN=example.com
|
||||
MAIL_FROM_ADDRESS=nextcloud
|
||||
SMTP_SECURE=ssl
|
||||
SMTP_HOST=smtp.sendgrid.net
|
||||
SMTP_PORT=465
|
||||
SMTP_NAME=apikey
|
||||
SMTP_PASSWORD=<sendgrid-api-key-goes-here>
|
||||
SMTP_SECURE=tls
|
||||
SMTP_HOST=smtp-relay.sendinblue.com
|
||||
SMTP_PORT=587
|
||||
SMTP_NAME=<registration-email@gmail.com>
|
||||
SMTP_PASSWORD=<smtp-key-goes-here>
|
||||
```
|
||||
|
||||
`nginx.conf`
|
||||
```
|
||||
I wont be pasting it here
|
||||
in full text,
|
||||
but it is included in this github repo.
|
||||
Not be pasted here, too long.
|
||||
It is included in this github repo.
|
||||
```
|
||||
|
||||
[nginx.conf](https://raw.githubusercontent.com/DoTheEvo/selfhosted-apps-docker/master/nextcloud/nginx.conf)
|
||||
|
@ -181,12 +186,6 @@ upstream php-handler {
|
|||
Which is named in the `.env` file.</br>
|
||||
If one does not exist yet: `docker network create caddy_net`
|
||||
|
||||
# notice
|
||||
|
||||
current issue, [redis version 6.0](https://github.com/nextcloud/server/issues/21913)
|
||||
|
||||
Therefore `image: redis:5.0.9-alpine` is used instead of `image: redis` like with the rest.
|
||||
|
||||
# Reverse proxy
|
||||
|
||||
[Nextcloud official documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/reverse_proxy_configuration.html)
|
||||
|
@ -197,12 +196,14 @@ Caddy v2 is used, details
|
|||
There are few extra directives here to fix some nextcloud warnings.
|
||||
|
||||
`Caddyfile`
|
||||
```
|
||||
```php
|
||||
nextcloud.{$MY_DOMAIN} {
|
||||
reverse_proxy nextcloud-web:80
|
||||
header Strict-Transport-Security max-age=31536000;
|
||||
redir /.well-known/carddav /remote.php/carddav 301
|
||||
redir /.well-known/caldav /remote.php/caldav 301
|
||||
redir /.well-known/webfinger /index.php/.well-known/webfinger 301
|
||||
redir /.well-known/nodeinfo /index.php/.well-known/nodeinfo 301
|
||||
reverse_proxy nextcloud-web:80
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -210,15 +211,15 @@ nextcloud.{$MY_DOMAIN} {
|
|||
|
||||
Nextcloud needs few moments to start, then there is the initial configuration,
|
||||
creating admin account.</br>
|
||||
If database env variables were not passed in to nextcloud-app
|
||||
then also the database info would be required here.
|
||||
If database env variables were not used then also the database info
|
||||
would be required here.
|
||||
|
||||
![first-run-pic](https://i.imgur.com/lv1x9GF.png)
|
||||
|
||||
The domain or IP you access nextcloud on this first run is added
|
||||
to `trusted_domains` in `config.php`.
|
||||
Changing the domain later on will throw *"Access through untrusted domain"* error.</br>
|
||||
Editing `nextcloud-data/config/config.php` and adding the new domain will fix it.
|
||||
Editing `nextcloud_data/config/config.php` and adding the new domain will fix it.
|
||||
|
||||
# Security & setup warnings
|
||||
|
||||
|
@ -256,7 +257,7 @@ If there is a problem accesing nextcloud from a mobile app,
|
|||
*"Please log in before granting access"*,
|
||||
and being stuck after logging in with the circle animation:
|
||||
|
||||
Edit `nextcloud-data/config/config.php`</br>
|
||||
Edit `nextcloud_data/config/config.php`</br>
|
||||
adding as the last line: `'overwriteprotocol' => 'https',`
|
||||
|
||||
# Extra info
|
||||
|
@ -337,7 +338,7 @@ The script must be **executable** - `chmod +x nextcloud-backup-script.sh`
|
|||
|
||||
Test run the script `sudo ./nextcloud-backup-script.sh`</br>
|
||||
The resulting database dump is in
|
||||
`nextcloud/nextcloud-data-db/BACKUP.nextcloud.database.sql`
|
||||
`nextcloud/nextcloud_data_db/BACKUP.nextcloud.database.sql`
|
||||
|
||||
#### Cronjob
|
||||
|
||||
|
@ -357,11 +358,11 @@ Assuming clean start.
|
|||
let them run so they create the file structure
|
||||
* down the containers: `docker-compose down`
|
||||
* delete the directories `config`, `data`, `themes` in the freshly created
|
||||
`nextcloud/nextcloud-data/`
|
||||
`nextcloud/nextcloud_data/`
|
||||
* from the backup of `/nextcloud/nextcloud-data/`, copy the directories
|
||||
`configs`, `data`, `themes` in to the new `/nextcloud/nextcloud-data/`
|
||||
* from the backup of `/nextcloud/nextcloud-data-db/`, copy the backup database
|
||||
named `BACKUP.nextcloud.database.sql` in to the new `/nextcloud/nextcloud-data-db/`
|
||||
* from the backup of `/nextcloud/nextcloud_data_db/`, copy the backup database
|
||||
named `BACKUP.nextcloud.database.sql` in to the new `/nextcloud/nextcloud_data_db/`
|
||||
* start the containers: `docker-compose up -d`
|
||||
* set the correct user ownership of the directories copied:</br>
|
||||
`docker exec --workdir /var/www/html nextcloud-app chown -R www-data:www-data config data themes`
|
||||
|
|
Loading…
Reference in New Issue