Compare commits

..

21 Commits

Author SHA1 Message Date
c7fd45b47f update(server): bump version to 24.0.9 2023-02-09 16:07:21 +01:00
8ff2a5878e update(nginx-fpm-proxy): update to 1.23.2 2022-10-31 10:47:20 +01:00
b02037f743 update(server): bump version to 24.0.6 2022-10-31 10:46:57 +01:00
63a291121a update(server): bump version to 24.0.4 2022-09-04 10:39:55 +02:00
69d76f3342 update(server): bump version to 24.0.3 2022-07-24 09:06:25 +02:00
f465c5d792 update(server): bump version to 24.0.2 2022-07-17 16:04:55 +02:00
29a145fe42 fix(nginx-fpm-proxy): compare fpm_socket against strings not sequences 2022-06-19 14:34:20 +02:00
f27abe9e42 chore(nginx-fpm-proxy): allow specifying multiple sockets as upstreams 2022-05-29 09:48:25 +02:00
e76e4beac0 chore(server): name socket after container name 2022-05-29 09:47:40 +02:00
b40bd1a383 update(server): bump version to 24.0.1 2022-05-29 09:46:58 +02:00
6acf6314eb update(server): bump version to 23.0.3 2022-04-03 14:42:06 +02:00
3e5ad9ac5d chore: bump version to 0.5.0 2021-12-12 18:31:53 +01:00
ed8f838092 update(server): bump version to 23.0.0 2021-12-12 18:31:12 +01:00
cd527b9faa feat(nginx-fpm-proxy): add ansible role for nginx-based frontend proxy 2021-12-04 09:38:55 +01:00
991b8c635c chore: bump version to 0.4.0
- Adds the role `ldap_user_backend` for managing ldap authentication backends in nextcloud
- Allow checking integrity of nextcloud apps
- Allow specifying type for server settings, avoid leaking secrets in ansible task names
2021-11-26 07:57:16 +01:00
63f45dc193 chore(server): do not leak secrets in ansible task names 2021-11-26 07:55:46 +01:00
c56b82121b chore(server): do not check mode when retrieving current config setting 2021-11-26 07:54:54 +01:00
e46c687b89 feat(ldap-user-backend): add role for managing ldap user backend in nextcloud 2021-11-21 12:39:33 +01:00
ea33ee5ea7 feat(apps): allow checking app integrity 2021-11-21 08:29:12 +01:00
a907549dc9 fix(apps): specify occ command 2021-11-01 16:40:45 +01:00
b1a1daf955 fix(server): specify value type when configuring settings 2021-10-28 17:56:05 +02:00
21 changed files with 601 additions and 6 deletions

View File

@ -13,6 +13,11 @@ and managing nextcloud installations
- [`roles/apps`](roles/apps/README.md): - [`roles/apps`](roles/apps/README.md):
For managing nextcloud apps in an already installed nextcloud For managing nextcloud apps in an already installed nextcloud
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):
Manages LDAP authentication sources in installed nextcloud instances.
- [`roles/nginx-fpm-proxy`](roles/nginx-fpm-proxy/README.md):
Reverse proxy role which connects to nextcloud using FPM
and serves static content.
## License ## License

View File

@ -1,10 +1,12 @@
namespace: finallycoffee namespace: finallycoffee
name: nextcloud name: nextcloud
version: 0.3.0 version: 0.5.0
readme: README.md readme: README.md
authors: authors:
- Johanna Dorothea Reichmann <transcaffeine@finallycoffee.eu> - 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:
"community.docker": "^1.10.0"
license: license:
- CNPLv7+ - CNPLv7+
build_ignore: build_ignore:

View File

@ -3,3 +3,5 @@
nextcloud_container_name: nextcloud nextcloud_container_name: nextcloud
nextcloud_apps: [] nextcloud_apps: []
nextcloud_run_user: nextcloud nextcloud_run_user: nextcloud
nextcloud_apps_check_integrity: false

View File

@ -48,3 +48,12 @@
loop: "{{ nextcloud_apps }}" loop: "{{ nextcloud_apps }}"
notify: notify:
- restart-nextcloud - restart-nextcloud
- name: Ensure app integrity
community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}"
command: "php occ integrity:check-app {{ item.name }}"
user: "{{ nextcloud_run_user }}"
tty: yes
when: nextcloud_apps_check_integrity and item.state|default('present') in ['latest', 'present']
loop: "{{ nextcloud_apps }}"

3
roles/apps/vars/main.yml Normal file
View File

@ -0,0 +1,3 @@
---
nc_apps_occ_command: "php occ"

View File

@ -0,0 +1,37 @@
# `finallycoffee.nextcloud.ldap-user-backend` ansible role
Ansible role for managing LDAP authentication of nextcloud instances using ansible.
## Prerequisites
This role assumes a nextcloud instance is up and running, and has the `user_ldap`
nextcloud app installed. For starting a nextcloud instance, see the
`finallycoffee.nextcloud.server` role, for managing nextcloud apps see the
`finallycoffee.nextcloud.apps` ansible role.
## Configuration
- Set `nc_ldap_api_method` to either `occ` or `http` to control wether the
configuration is set using `php occ` command line calls or the `http` API
of the `user_ldap` nextcloud app.
- For `nc_ldap_api_method: occ`, ensure `nc_ldap_container` is set to the name
of the docker container where nextcloud is running, and `nc_ldap_occ_user` is
the user the container / nextcloud itself runs as. `nc_ldap_occ_command`
_can_ also be tweaked if `php` is not in the path, but the default should
be fine in most cases.
- For `nc_ldap_api_method: http`, ensure `nc_ldapi_api_instance_url` contains
the URL to the nextcloud server, including protocol (and port, if
non-standard), and `nc_ldap_api_basic_auth_[user|password]` contain the
credentials of an admin user with the rights to edit the LDAP settings.
- Set `nc_ldap_test_configuration` to `true`/`false` to have the role issue a
nextcloud-provided test of the configured LDAP configuration, this corresponds
to a `occ ldap:test-config <id>`.
For most of the options, see the
[nextcloud manual on configuration keys](https://docs.nextcloud.com/server/latest/admin_manual/configuration_user/user_auth_ldap_api.html#configuration-keys),
the config keys are mapped 1:1 with a prefix of `nc_ldap_config_` and
the so-called "snake-case" (`ldap_backup_host`), so `ldapUserFilterMode` becomes
`nc_ldap_config_ldap_user_filter_mode`.

View File

@ -0,0 +1,67 @@
---
nc_ldap_api_method: occ
nc_ldap_test_configuration: true
nc_ldap_api_instance_url: http://localhost
nc_ldap_api_basic_auth_user:
nc_ldap_api_basic_auth_password:
nc_ldap_occ_command: "php occ"
nc_ldap_occ_user: "nextcloud"
nc_ldap_container: nextcloud
nc_ldap_config_id: s01
nc_ldap_config_host: 127.0.0.1
nc_ldap_config_port: 389
nc_ldap_config_backup_host: ~
nc_ldap_config_backup_port: ~
nc_ldap_config_base_dn:
nc_ldap_config_base_dn_users:
nc_ldap_config_base_dn_groups:
nc_ldap_config_agent_name:
nc_ldap_config_agent_password:
nc_ldap_config_override_main_server: ~
nc_ldap_config_tls: ~
nc_ldap_config_turn_off_cert_check: ~
nc_ldap_config_user_displayname: ~
nc_ldap_config_user_displayname2: ~
nc_ldap_config_user_avatar_rule: ~
nc_ldap_config_gid_number: ~
nc_ldap_config_user_filter_objectclass: ~
nc_ldap_config_user_filter_groups: ~
nc_ldap_config_user_filter: ~
nc_ldap_config_user_filter_mode: ~
nc_ldap_config_attributes_for_user_search: ~
nc_ldap_config_group_filter: ~
nc_ldap_config_group_filter_mode: ~
nc_ldap_config_group_filter_objectclass: ~
nc_ldap_config_group_filter_groups: ~
nc_ldap_config_group_member_assoc_attr: ~
nc_ldap_config_group_displayname: ~
nc_ldap_config_attributes_for_group_search: ~
nc_ldap_config_login_filter: ~
nc_ldap_config_login_filter_mode: ~
nc_ldap_config_login_filter_email: ~
nc_ldap_config_login_filter_username: ~
nc_ldap_config_login_filter_attributes: ~
nc_ldap_config_quota_attribute: ~
nc_ldap_config_quota_default: ~
nc_ldap_config_email_attribute: ~
nc_ldap_config_cache_ttl: ~
nc_ldap_config_configuration_active: ~
nc_ldap_config_experienced_admin: ~
nc_ldap_config_home_folder_naming_rule: ~
nc_ldap_config_use_memberOf_to_detect_membership: ~
nc_ldap_config_expert_username_attr: ~
nc_ldap_config_expert_uuid_user_attr: ~
nc_ldap_config_expert_uuid_group_attr: ~
nc_ldap_config_nested_groups: ~
nc_ldap_config_paging_size: ~
nc_ldap_config_turn_on_password_change: ~
nc_ldap_config_dynamic_group_member_url: ~
nc_ldap_config_default_ppolicy_dn: ~
nc_ldap_meta_http_agent: "ansible-httpget/finallycoffee.nextcloud.ldap-user-backend"

View File

@ -0,0 +1,4 @@
---
collections:
- community.docker

View File

@ -0,0 +1,49 @@
---
- name: Set default api parameters for HTTP
meta: noop
vars: &api_defaults
http_agent: "{{ nc_ldap_meta_http_agent }}"
headers: "{{ nc_ldap_api_headers }}"
url_username: "{{ nc_ldap_api_basic_auth_user }}"
url_password: "{{ nc_ldap_api_basic_auth_password }}"
force_basic_auth: yes
force: yes
- name: Check if configuration with given config ID already exists
uri:
<<: *api_defaults
url: "{{ nc_ldap_api_path }}/{{ nc_ldap_config_id }}{{ query_params }}"
method: GET
vars:
query_params: "?showPassword={{ '1' if nc_ldap_config_agent_password else '0' }}&format={{nc_ldap_api_parameter_format }}"
register: nc_ldap_existing_config_api
# TODO: Can we force an ID on POST?
- name: Create ldap configuration with id={{ nc_ldap_config_id }}
uri:
<<: *api_defaults
url: "{{ nc_ldap_api_path }}"
method: POST
when: nc_ldap_existing_config_api.status != 200
- name: Parse output of query command to dict
set_fact:
nc_ldap_existing_config: "{{ nc_ldap_existing_config_api.stdout | from_json }}"
changed_when: false
- name: Create changeset
set_fact:
nc_ldap_config_changeset: "{{ nc_ldap_config_changeset | combine(changed_entry) }}"
vars:
changed_entry: "{{ { item : nc_ldap_config_keys[item] } }}"
loop: "{{ nc_ldap_config_keys.keys() }}"
when: nc_ldap_config_keys[item] is defined and nc_ldap_config_keys[item] and nc_ldap_config_keys[item] != nc_ldap_existing_config[nc_ldap_config_id][item]
- name: Ensure ldap configuration is in sync (http)
uri:
<<: *api_defaults
url: "{{ nc_lap_api_path }}/{{ nc_ldap_config_id }}"
method: PUT
body: "{{ { 'configData': nc_ldap_config_changeset } }}"
body_format: "form-urlencoded"

View File

@ -0,0 +1,49 @@
---
- name: Check if configuration with given config ID already exists
docker_container_exec:
container: "{{ nc_ldap_container }}"
command: "{{ nc_ldap_occ_command }} ldap:show-config --output json {{ '--show-password' if nc_ldap_config_agent_password else '' }} {{ nc_ldap_config_id }}"
user: "{{ nc_ldap_occ_user }}"
tty: yes
changed_when: false
check_mode: false
register: nc_ldap_existing_config_occ
- name: Create ldap configuration with id={{ nc_ldap_config_id }}
docker_container_exec:
container: "{{ nc_ldap_container }}"
command: "{{ nc_ldap_occ_command }} ldap:create-empty-config --output json {{ nc_ldap_config_id }}"
user: "{{ nc_ldap_occ_user }}"
tty: yes
when: nc_ldap_existing_config_occ.rc != 0 and nc_ldap_config_id not in (nc_ldap_existing_config_occ.stdout | from_json).keys()
- name: Parse output of query command to dict
set_fact:
nc_ldap_existing_config: "{{ nc_ldap_existing_config_occ.stdout | from_json }}"
changed_when: false
- name: Create changeset
set_fact:
nc_ldap_config_changeset: "{{ nc_ldap_config_changeset | combine(changed_entry) }}"
vars:
changed_entry: "{{ { item : nc_ldap_config_keys[item] } }}"
loop: "{{ nc_ldap_config_keys.keys() }}"
when: nc_ldap_config_keys[item] is defined and nc_ldap_config_keys[item] and nc_ldap_config_keys[item] != nc_ldap_existing_config[nc_ldap_config_id][item]
- name: Ensure ldap configuration is in sync
docker_container_exec:
container: "{{ nc_ldap_container }}"
command: "{{ nc_ldap_occ_command }} ldap:set-config \"{{ nc_ldap_config_id }}\" \"{{ item.key }}\" \"{{ item.value }}\""
user: "{{ nc_ldap_occ_user }}"
tty: yes
loop: "{{ nc_ldap_config_changeset | dict2items }}"
- name: Ensure ldap configuration is working
docker_container_exec:
container: "{{ nc_ldap_container }}"
command: "{{ nc_ldap_occ_command }} ldap:test-config {{ nc_ldap_config_id }}"
user: "{{ nc_ldap_occ_user }}"
tty: yes
changed_when: false
when: nc_ldap_test_configuration

View File

@ -0,0 +1,10 @@
---
- name: Load config {{ nc_ldap_config_id }} (and create if not exists) when running mode is http
include_tasks: load_config_http.yml
when: nc_ldap_api_method == 'http'
- name: Load config {{ nc_ldap_config_id }} (and create if not exists) when running mode is occ
include_tasks: load_config_occ.yml
when: nc_ldap_api_method == 'occ'

View File

@ -0,0 +1,60 @@
---
nc_ldap_api_path: "/ocs/v2.php/apps/user_ldap/api/v1/config"
nc_ldap_api_url: "{{ nc_ldap_api_instance_url }}{{ nc_ldap_api_path }}"
nc_ldap_api_headers:
OCS-APIREQUEST: "true"
nc_ldap_api_parameter_format: json
nc_ldap_config_keys:
ldapHost: "{{ nc_ldap_config_host }}"
ldapPort: "{{ nc_ldap_config_port }}"
ldapBackupHost: "{{ nc_ldap_config_backup_host }}"
ldapBackupPort: "{{ nc_ldap_config_backup_port }}"
ldapOverrideMainServer: "{{ nc_ldap_config_override_main_server }}"
ldapBase: "{{ nc_ldap_config_base_dn }}"
ldapBaseUsers: "{{ nc_ldap_config_base_dn_users }}"
ldapBaseGroups: "{{ nc_ldap_config_base_dn_groups }}"
ldapAgentName: "{{ nc_ldap_config_agent_name }}"
ldapAgentPassword: "{{ nc_ldap_config_agent_password }}"
ldapTLS: "{{ nc_ldap_config_tls }}"
turnOffCertCheck: "{{ nc_ldap_config_turn_off_cert_check }}"
ldapUserDisplayName: "{{ nc_ldap_config_user_displayname }}"
ldapUserDisplayName2: "{{ nc_ldap_config_user_displayname2 }}"
ldapUserAvatarRule: "{{ nc_ldap_config_user_avatar_rule }}"
ldapGidNumber: "{{ nc_ldap_config_gid_number }}"
ldapUserFilterObjectclass: "{{ nc_ldap_config_user_filter_objectclass }}"
ldapUserFilterGroups: "{{ nc_ldap_config_user_filter_groups }}"
ldapUserFilter: "{{ nc_ldap_config_user_filter }}"
ldapUserFilterMode: "{{ nc_ldap_config_user_filter_mode }}"
ldapAttributesForUserSearch: "{{ nc_ldap_config_attributes_for_user_search }}"
ldapGroupFilter: "{{ nc_ldap_config_group_filter }}"
ldapGroupFilterMode: "{{ nc_ldap_config_group_filter_mode }}"
ldapGroupFilterObjectclass: "{{ nc_ldap_config_group_filter_objectclass }}"
ldapGroupFilterGroups: "{{ nc_ldap_config_group_filter_groups }}"
ldapGroupMemberAssocAttr: "{{ nc_ldap_config_group_member_assoc_attr }}"
ldapGroupDisplayName: "{{ nc_ldap_config_group_displayname }}"
ldapAttributesForGroupSearch: "{{ nc_ldap_config_attributes_for_group_search }}"
ldapLoginFilter: "{{ nc_ldap_config_login_filter }}"
ldapLoginFilterMode: "{{ nc_ldap_config_login_filter_mode }}"
ldapLoginFilterEmail: "{{ nc_ldap_config_login_filter_email }}"
ldapLoginFilterUsername: "{{ nc_ldap_config_login_filter_username }}"
ldapLoginFilterAttributes: "{{ nc_ldap_config_login_filter_attributes }}"
ldapQuotaAttribute: "{{ nc_ldap_config_quota_attribute }}"
ldapQuotaDefault: "{{ nc_ldap_config_quota_default }}"
ldapEmailAttribute: "{{ nc_ldap_config_email_attribute }}"
ldapCacheTTL: "{{ nc_ldap_config_cache_ttl }}"
ldapConfigurationActive: "{{ nc_ldap_config_configuration_active }}"
ldapExperiencedAdmin: "{{ nc_ldap_config_experienced_admin }}"
homeFolderNamingRule: "{{ nc_ldap_config_home_folder_naming_rule }}"
useMemberOfToDetectMembership: "{{ nc_ldap_config_use_memberOf_to_detect_membership }}"
ldapExpertUsernameAttr: "{{ nc_ldap_config_expert_username_attr }}"
ldapExpertUUIDUserAttr: "{{ nc_ldap_config_expert_uuid_user_attr }}"
ldapExpertUUIDGroupAttr: "{{ nc_ldap_config_expert_uuid_group_attr }}"
ldapNestedGroups: "{{ nc_ldap_config_nested_groups }}"
ldapPagingSize: "{{ nc_ldap_config_paging_size }}"
turnOnPasswordChange: "{{ nc_ldap_config_turn_on_password_change }}"
ldapDynamicGroupMemberURL: "{{ nc_ldap_config_dynamic_group_member_url }}"
ldapDefaultPPolicyDN: "{{ nc_ldap_config_default_ppolicy_dn }}"
nc_ldap_config_changeset: {}

View File

@ -0,0 +1,22 @@
# `finallycoffee.nextcloud.nginx-fpm-proxy` ansible role
Ansible role for serving nextcloud static content and connecting to dynamic content via PHP-FPM.
## Prerequisites
A running nextcloud instance with FPM available either via IP+port or a unix socket.
## Configuration
- Set `nextcloud_nginx_data_path` to the data directory of the nextcloud instance,
from where static content etc is served from.
- `nextcloud_nginx_storage_path` needs to be set to the storage path of the nextcloud
instance, where user data is stored. Usually this is `{{ nextcloud_nginx_data_path }}/data`.
- Set `nextcloud_nginx_fpm_socket_dir` to the directory containing the FPM socket,
called `nextcloud.sock` by default. This can be overridden in `nextcloud_nginx_fpm_socket_path`.
- If FPM is not used via a unix socket, set `nextcloud_nginx_fpm_server_ip` and
`nextcloud_nginx_fpm_server_port` accordingly. Note that the IP must be reachable
from inside the nginx container.

View File

@ -0,0 +1,23 @@
---
nextcloud_nginx_version: "1.23.2"
nextcloud_nginx_basepath: /opt/nextcloud-nginx
nextcloud_nginx_config: "{{ nextcloud_nginx_basepath }}/nextcloud.conf"
nextcloud_nginx_servernames: ~
nextcloud_nginx_container_name: nextcloud_nginx
nextcloud_nginx_container_image: "docker.io/library/nginx"
nextcloud_nginx_container_image_flavor: "alpine"
nextcloud_nginx_container_image_ref: "{{ nextcloud_nginx_container_image }}:{{ nextcloud_nginx_version }}{{ '-' + nextcloud_nginx_container_image_flavor if nextcloud_nginx_container_image_flavor else ''}}"
nextcloud_nginx_container_image_force_pull: false
nextcloud_nginx_container_extra_volumes: []
nextcloud_nginx_container_extra_labels: {}
nextcloud_nginx_container_extra_env: {}
nextcloud_nginx_container_restart_policy: unless-stopped
nextcloud_nginx_fpm_server_ip: ~
nextcloud_nginx_fpm_server_port: 9000
nextcloud_nginx_fpm_socket_dir: ~
nextcloud_nginx_fpm_socket_path: "{{ nextcloud_nginx_fpm_socket_dir }}/nextcloud.sock"
nextcloud_nginx_data_path: ~
nextcloud_nginx_storage_path: ~

View File

@ -0,0 +1,8 @@
---
- name: Restart nextcloud nginx fpm proxy container
listen: restart-nextcloud-nginx
docker_container:
name: "{{ nextcloud_nginx_container_name }}"
state: started
restart: yes

View File

@ -0,0 +1,36 @@
---
- name: Create directory for nginx config
file:
path: "{{ nextcloud_nginx_basepath }}"
state: directory
mode: 0750
- name: Template nginx reverse proxy config for nextcloud
template:
src: nextcloud-nginx.conf.j2
dest: "{{ nextcloud_nginx_config }}"
vars:
fpm_server: "{{ nextcloud_nginx_fpm_server_ip }}"
fpm_server_port: "{{ nextcloud_nginx_fpm_server_port }}"
fpm_socket: "{{ nextcloud_nginx_fpm_socket_path }}"
domain: "{{ nextcloud_nginx_servernames }}"
notify: restart-nextcloud-nginx
- name: Ensure nginx docker image is pulled
docker_image:
name: "{{ nextcloud_nginx_container_image_ref }}"
state: present
source: pull
force_source: "{{ nextcloud_nginx_container_image_force_pull }}"
- name: Ensure nginx is running for FPM and static file serving
docker_container:
name: "{{ nextcloud_nginx_container_name }}"
image: "{{ nextcloud_nginx_container_image_ref }}"
volumes: "{{ nextcloud_nginx_container_volumes }}"
labels: "{{ nextcloud_nginx_container_labels }}"
env: "{{ nextcloud_nginx_container_env }}"
networks: "{{ nextcloud_nginx_container_networks | default(omit) }}"
restart_policy: "{{ nextcloud_nginx_container_restart_policy }}"
state: started

View File

@ -0,0 +1,180 @@
upstream php-handler {
{% if fpm_socket %}
{% if fpm_socket is not string %}
{% for upstream in fpm_socket %}
server unix:{{ upstream }};
{% endfor %}
{% else %}
server unix:{{ fpm_socket }};
{% endif %}
{% else %}
server {{ fpm_server }}:{{ fpm_server_port }};
{% endif %}
}
server {
listen 80;
listen [::]:80;
server_name {{ domain | join(' ') }};
# 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;
# 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/nextcloud;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# 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 https://$host/remote.php/dav/; }
location = /.well-known/caldav { return 301 https://$host/remote.php/dav/; }
# The following rule is only needed for the Social app.
# 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/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 https://$host/index.php$request_uri;
}
# set max upload size
client_max_body_size {{ nextcloud_php_upload_limit }};
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;
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;
try_files $fastcgi_script_name =404;
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 HTTPS $https;
fastcgi_param HTTP_PROXY "";
fastcgi_param REMOTE_ADDR $remote_addr;
# Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
# Enable pretty urls
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
include fastcgi_params;
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)$ {
expires 1d;
# How `sendfile`, `tcp_nopush` and `tcp_nodelay` interact
# https://thoughts.t37.net/nginx-optimization-understanding-sendfile-tcp-nodelay-and-tcp-nopush-c55cdd276765?gi=f11af534b564
sendfile on; # use `sendfile` syscall, which is a DMA (zero-copy) call
tcp_nopush on; # wait until the file is fully "read"
tcp_nodelay on; # always immediately flush, never wait for a full packet worth of data (default wait interval = 200ms)
aio on; #async IO for files
open_file_cache max=10000; # cache metadata for up to 10000 files
open_file_cache_valid 3600s; # previous cache is valid for 1h
open_file_cache_errors off; # except if there was an error, that is not cached
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)$ {
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;
# Optional: Don't log access to other assets
access_log off;
}
}

View File

@ -0,0 +1,18 @@
---
nextcloud_nginx_container_volumes_base: >-2
{{
[
nextcloud_nginx_config + ':/etc/nginx/conf.d/nextcloud.conf:ro',
nextcloud_nginx_data_path + ':/var/www/nextcloud:ro',
nextcloud_nginx_storage_path + ':/var/www/nextcloud/data:rw'
]
+ ([nextcloud_nginx_fpm_socket_dir + ':' + nextcloud_nginx_fpm_socket_dir + ':rw'] if nextcloud_nginx_fpm_socket_dir else [])
}}
nextcloud_nginx_container_labels_base:
version: "{{ nextcloud_nginx_version }}"
nextcloud_nginx_container_env_base: {}
nextcloud_nginx_container_volumes: "{{ nextcloud_nginx_container_volumes_base + nextcloud_nginx_container_extra_volumes }}"
nextcloud_nginx_container_labels: "{{ nextcloud_nginx_container_labels_base | combine(nextcloud_nginx_container_extra_labels) }}"
nextcloud_nginx_container_env: "{{ nextcloud_nginx_container_env_base | combine(nextcloud_nginx_container_extra_env) }}"

View File

@ -1,6 +1,6 @@
--- ---
nextcloud_version: 22.2.0 nextcloud_version: 24.0.9
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"

View File

@ -1,6 +1,6 @@
--- ---
- name: Ensure {{ key }} is set to {{ value }} - name: Ensure {{ key }} is set to {{ '***' if ['pass', 'secret', 'key']|select('in', key) else value }}
block: block:
- name: Check value of {{ key }} - name: Check value of {{ key }}
community.docker.docker_container_exec: community.docker.docker_container_exec:
@ -9,18 +9,29 @@
user: "{{ nextcloud_user_info.uid }}" user: "{{ nextcloud_user_info.uid }}"
tty: yes tty: yes
register: nextcloud_current_config_entry register: nextcloud_current_config_entry
check_mode: false
changed_when: false changed_when: false
- name: Set {{ key }} to {{ value }} - name: Set {{ key }} to {{ '***' if (['pass', 'secret', 'key']|select('in', key)) else value }}
community.docker.docker_container_exec: community.docker.docker_container_exec:
container: "{{ nextcloud_container_name }}" container: "{{ nextcloud_container_name }}"
command: "{{ nextcloud_occ_command }} config:{{ type }}:set {{ scope }} {{ entry }} --value={{ value }} -n" command: "{{ nextcloud_occ_command }} config:{{ type }}:set {{ scope }} {{ entry }} --type={{ value_type }} --value={{ value }} -n"
user: "{{ nextcloud_user_info.uid }}" user: "{{ nextcloud_user_info.uid }}"
tty: yes tty: yes
when: nextcloud_current_config_entry.stdout != value when: nextcloud_current_config_entry.stdout != value
notify: restart-nextcloud notify: restart-nextcloud
vars: vars:
entry_path: "{{ key.split('.') }}" entry_path: "{{ key.split('.') }}"
value_type: >-
{% if value is boolean %}
boolean
{% elsif value is integer %}
integer
{% elsif value is float %}
float
{% else %}
string
{% endif %}
type: "{{ entry_path | first }}" type: "{{ entry_path | first }}"
scope: "{{ entry_path[1] if entry_path | length > 2 else '' }}" scope: "{{ entry_path[1] if entry_path | length > 2 else '' }}"
entry: >- entry: >-

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.sock listen = {{ nextcloud_container_php_socket_path }}/{{ nextcloud_container_name }}.sock
listen.owner = www-data listen.owner = www-data
listen.group = www-data listen.group = www-data
listen.mode = 0666 listen.mode = 0666