Compare commits

..

1 Commits

19 changed files with 87 additions and 129 deletions

View File

@ -15,7 +15,7 @@ and managing nextcloud installations
server instance. Can install, remove, enable/disable and update apps. server instance. Can install, remove, enable/disable and update apps.
- [`roles/ldap-user-backend`](roles/ldap-user-backend/README.md): - [`roles/ldap-user-backend`](roles/ldap-user-backend/README.md):
Manages LDAP authentication sources in installed nextcloud instances. Manages LDAP authentication sources in installed nextcloud instances.
- [`roles/nginx-fpm-proxy`](roles/nginx-fpm-proxy/README.md): - [`roles/nginx-fpm-proxy`](roles/nginx-fpm-proxy/README.me):
Reverse proxy role which connects to nextcloud using FPM Reverse proxy role which connects to nextcloud using FPM
and serves static content. and serves static content.

View File

@ -1,14 +1,15 @@
namespace: finallycoffee namespace: finallycoffee
name: nextcloud name: nextcloud
version: 0.5.1 version: 0.4.0
readme: README.md readme: README.md
authors: authors:
- transcaffeine <transcaffeine@finally.coffee> - Johanna Dorothea Reichmann <transcaffeine@finallycoffee.eu>
description: Installing and configuring nextcloud (and related apps/services) using docker description: Installing and configuring nextcloud (and related apps/services) using docker
dependencies: dependencies:
"community.docker": "^1.10.0" "community.docker": "^1.10.0"
license_file: LICENSE.md license:
- CNPLv7+
build_ignore: build_ignore:
- '*.tar.gz' - '*.tar.gz'
repository: https://git.finally.coffee/finallycoffee/nextcloud repository: https://git.finallycoffee.eu/finallycoffee.eu/nextcloud
issues: https://git.finally.coffee/finallycoffee/nextcloud/issues issues: https://git.finallycoffee.eu/finallycoffee.eu/nextcloud/issues

View File

@ -1,3 +0,0 @@
---
requires_ansible: ">=2.12"

View File

@ -1,6 +1,6 @@
--- ---
nextcloud_nginx_version: "1.25.3" nextcloud_nginx_version: "1.21.3"
nextcloud_nginx_basepath: /opt/nextcloud-nginx nextcloud_nginx_basepath: /opt/nextcloud-nginx
nextcloud_nginx_config: "{{ nextcloud_nginx_basepath }}/nextcloud.conf" nextcloud_nginx_config: "{{ nextcloud_nginx_basepath }}/nextcloud.conf"
nextcloud_nginx_servernames: ~ nextcloud_nginx_servernames: ~

View File

@ -1,12 +1,6 @@
upstream php-handler { upstream php-handler {
{% if fpm_socket %} {% if fpm_socket %}
{% if fpm_socket is not string %}
{% for upstream in fpm_socket %}
server unix:{{ upstream }};
{% endfor %}
{% else %}
server unix:{{ fpm_socket }}; server unix:{{ fpm_socket }};
{% endif %}
{% else %} {% else %}
server {{ fpm_server }}:{{ fpm_server_port }}; server {{ fpm_server }}:{{ fpm_server_port }};
{% endif %} {% endif %}
@ -17,79 +11,29 @@ server {
listen [::]:80; listen [::]:80;
server_name {{ domain | join(' ') }}; server_name {{ domain | join(' ') }};
# Path to the root of your installation
root /var/www/nextcloud;
# Add headers to serve security related headers # Add headers to serve security related headers
# Before enabling Strict-Transport-Security headers please read into this # Before enabling Strict-Transport-Security headers please read into this
# topic first. # topic first.
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always;
#
# Prevent nginx HTTP Server Detection # WARNING: Only add the preload option once you read about
server_tokens off; # the consequences in https://hstspreload.org/. This option
# will add the domain to a hardcoded list that is shipped
# set max upload size # in all major browsers and getting removed from this list
client_max_body_size {{ nextcloud_php_upload_limit }}; # could take several months.
client_body_timeout 300s;
fastcgi_buffers 128 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;
# 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;
# HTTP response headers borrowed from Nextcloud `.htaccess`
add_header Referrer-Policy "no-referrer" always; add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" 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-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "noindex, nofollow" always; add_header X-Robots-Tag "none" always;
add_header X-XSS-Protection "1; mode=block" always; add_header X-XSS-Protection "1; mode=block" always;
# Remove X-Powered-By, which is an information leak # Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By; fastcgi_hide_header X-Powered-By;
# Set .mjs and .wasm MIME types # Path to the root of your installation
# Either include it in the default mime.types list root /var/www/nextcloud;
# and include that list explicitly or add the file extension
# only for Nextcloud like below:
include mime.types;
types {
text/javascript js;
application/javascript mjs;
application/wasm wasm;
}
# 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;
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
location = / {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 /remote.php/webdav/$is_args$args;
}
}
location = /robots.txt { location = /robots.txt {
allow all; allow all;
@ -105,55 +49,81 @@ server {
# The rules in this block are an adaptation of the rules # The rules in this block are an adaptation of the rules
# in `.htaccess` that concern `/.well-known`. # in `.htaccess` that concern `/.well-known`.
location = /.well-known/carddav { return 301 https://$host/remote.php/dav; } location = /.well-known/carddav { return 301 https://$host/remote.php/dav/; }
location = /.well-known/caldav { return 301 https://$host/remote.php/dav; } location = /.well-known/caldav { return 301 https://$host/remote.php/dav/; }
location = /.well-known/webfinger { return 301 https://$host/index.php/.well-known/webfinger; } # The following rule is only needed for the Social app.
location = /.well-known/nodeinfo { return 301 https://$host/index.php/.well-known/nodeinfo; } # Uncomment it if you're planning to use this app.
location = /.well-known/webfinger { return 301 https://$host/public.php?service=webfinger; }
# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
location = /.well-known/host-meta { return 301 https://$host/public.php?service=host-meta; }
location = /.well-known/host-meta.json { return 301 https://$host/public.php?service=host-meta-json; }
location /.well-known/acme-challenge { try_files $uri $uri/ =404; } location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
location /.well-known/pki-validation { 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 # Let Nextcloud's API for `/.well-known` URIs handle all other
# requests by passing them to the front-end controller. # requests by passing them to the front-end controller.
return 301 /index.php$request_uri; return 301 https://$host/index.php$request_uri;
} }
# Rules borrowed from `.htaccess` to hide certain paths from clients # set max upload size
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } client_max_body_size {{ nextcloud_php_upload_limit }};
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } fastcgi_buffers 128 4K;
# Ensure this block, which passes PHP files to the PHP process, is above the blocks # Enable gzip but do not remove ETag headers
# which handle static assets (as seen below). If this block is not declared first, gzip on;
# then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` gzip_vary on;
# to the URI, resulting in a HTTP 500 error response. gzip_comp_level 4;
location ~ \.php(?:$|/) { gzip_min_length 256;
# Required for legacy support gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri; 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;
fastcgi_split_path_info ^(.+?\.php)(/.*)$; # 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\/.+|.+\/richdocumentscode\/proxy)\.php(?:$|\/) {
fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;
set $path_info $fastcgi_path_info; set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404; try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /var/www/html$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param PATH_INFO $path_info; fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS on; fastcgi_param HTTPS $https;
fastcgi_param HTTP_PROXY "";
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param front_controller_active true; # Enable pretty urls # Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
# Enable pretty urls
fastcgi_param front_controller_active true;
fastcgi_pass php-handler; fastcgi_pass php-handler;
include fastcgi_params;
fastcgi_intercept_errors on; fastcgi_intercept_errors on;
fastcgi_request_buffering off; fastcgi_request_buffering off;
}
fastcgi_max_temp_file_size 0; location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
try_files $uri/ =404;
index index.php;
} }
# Adding the cache control header for js, css and map files # Adding the cache control header for js, css and map files
# Make sure it is BELOW the PHP block # Make sure it is BELOW the PHP block
location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ { location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
expires 1d; expires 1d;
# How `sendfile`, `tcp_nopush` and `tcp_nodelay` interact # How `sendfile`, `tcp_nopush` and `tcp_nodelay` interact
# https://thoughts.t37.net/nginx-optimization-understanding-sendfile-tcp-nodelay-and-tcp-nopush-c55cdd276765?gi=f11af534b564 # https://thoughts.t37.net/nginx-optimization-understanding-sendfile-tcp-nodelay-and-tcp-nopush-c55cdd276765?gi=f11af534b564
@ -189,19 +159,16 @@ server {
access_log off; access_log off;
} }
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {
location ~ \.woff2?$ { expires 1d;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
open_file_cache max=10000;
open_file_cache_valid 3600s;
open_file_cache_errors off;
try_files $uri /index.php$request_uri; try_files $uri /index.php$request_uri;
expires 7d; # Cache-Control policy borrowed from `.htaccess` # Optional: Don't log access to other assets
access_log off; # Optional: Don't log access to 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;
} }
} }

View File

@ -12,10 +12,3 @@ so the host file permissions remain comprehensible.
- `nextcloud_socket_path`: Setting this (to, for example, `{{ nextcloud_basepath }}/socket`), - `nextcloud_socket_path`: Setting this (to, for example, `{{ nextcloud_basepath }}/socket`),
will make FPM listen on `{{ nextcloud_socket_path }}/nextcloud.sock` on the host, enabling will make FPM listen on `{{ nextcloud_socket_path }}/nextcloud.sock` on the host, enabling
you to use FPM to interface with nextcloud. you to use FPM to interface with nextcloud.
### Redis over UNIX-Socket
Set `REDIS_HOST` to a path in the container where the socket is mapped using
`nextcloud_container_extra_environment`. Also set `REDIS_HOST_PORT` to 0
explicitely, as `redis.config.php` will set it to `null` otherwise, resulting
in an exception. Set your redis password in `REDIS_HOST_PASSWORD`.

View File

@ -1,6 +1,6 @@
--- ---
nextcloud_version: 28.0.8 nextcloud_version: 22.2.0
nextcloud_user: nextcloud nextcloud_user: nextcloud
nextcloud_basepath: /opt/nextcloud nextcloud_basepath: /opt/nextcloud
nextcloud_config_path: "{{ nextcloud_basepath }}/config" nextcloud_config_path: "{{ nextcloud_basepath }}/config"
@ -46,19 +46,19 @@ nextcloud_container_purge_other_networks: true
nextcloud_paths: nextcloud_paths:
- path: "{{ nextcloud_config_path }}" - path: "{{ nextcloud_config_path }}"
mode: "0755" mode: "0755"
owner: "{{ nextcloud_user_info.uid | default(nextcloud_user) }}" owner: "{{ nextcloud_user_info.uid|default(nextcloud_user) }}"
group: root group: "root"
- path: "{{ nextcloud_data_path }}" - path: "{{ nextcloud_data_path }}"
mode: "0755" mode: "0755"
owner: "{{ nextcloud_user_info.uid | default(nextcloud_user) }}" owner: "{{ nextcloud_user_info.uid|default(nextcloud_user) }}"
group: "{{ nextcloud_user_info.group | default(nextcloud_user) }}" group: "{{ nextcloud_user_info.uid|default(nextcloud_user) }}"
- path: "{{ nextcloud_fpm_config_path }}" - path: "{{ nextcloud_fpm_config_path }}"
mode: "0750" mode: "0750"
owner: root owner: root
group: root group: root
- path: "{{ nextcloud_storage_path }}" - path: "{{ nextcloud_storage_path }}"
mode: "0770" mode: "0770"
owner: "{{ nextcloud_user_info.uid | default(nextcloud_user) }}" owner: "{{ nextcloud_user_info.uid|default(nextcloud_user) }}"
group: "root" group: "root"
# PHP OpCache tuning # PHP OpCache tuning

View File

@ -4,7 +4,7 @@ user = www-data
group = www-data group = www-data
{% if nextcloud_socket_path is defined and nextcloud_socket_path is string %} {% if nextcloud_socket_path is defined and nextcloud_socket_path is string %}
listen = {{ nextcloud_container_php_socket_path }}/{{ nextcloud_container_name }}.sock listen = {{ nextcloud_container_php_socket_path }}/nextcloud.sock
listen.owner = www-data listen.owner = www-data
listen.group = www-data listen.group = www-data
listen.mode = 0666 listen.mode = 0666