From 7c25a0c20cb810039cefda5dca03bd1727a834c7 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Thu, 12 Dec 2019 20:57:02 +0100 Subject: [PATCH] nextcloud: fix the nginx virtualhost. The local postgresql server is now optional. --- library/roles/nextcloud/defaults/main.yml | 3 +- library/roles/nextcloud/meta/main.yml | 2 +- .../nextcloud/templates/nginx-virthost.conf | 49 +++++++++++-------- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/library/roles/nextcloud/defaults/main.yml b/library/roles/nextcloud/defaults/main.yml index 5fc38f9c..2e5e0a20 100644 --- a/library/roles/nextcloud/defaults/main.yml +++ b/library/roles/nextcloud/defaults/main.yml @@ -1,9 +1,10 @@ --- -nextcloud_version: 15.0.5 +nextcloud_version: 17.0.1 nextcloud_dist_filename: 'nextcloud-{{ nextcloud_version }}.tar.bz2' nextcloud_download_url: 'https://download.nextcloud.com/server/releases/{{ nextcloud_dist_filename }}' nextcloud_use_redis: True nextcloud_use_memcache: False +nextcloud_local_postgresql: True nextcloud_web_basedir: /var/www nextcloud_web_root: '{{ nextcloud_web_basedir }}/nextcloud' nextcloud_data_base_dir: /srv diff --git a/library/roles/nextcloud/meta/main.yml b/library/roles/nextcloud/meta/main.yml index 4be987f3..8a561dcf 100644 --- a/library/roles/nextcloud/meta/main.yml +++ b/library/roles/nextcloud/meta/main.yml @@ -1,6 +1,6 @@ --- dependencies: - - { role: '../../library/roles/postgresql' } + - { role: '../../library/roles/postgresql', when: nextcloud_local_postgresql } - { role: '../../library/roles/php-fpm' } - { role: '../../library/roles/nginx' } - { role: '../../library/roles/redis', when nextcloud_use_redis } diff --git a/library/roles/nextcloud/templates/nginx-virthost.conf b/library/roles/nextcloud/templates/nginx-virthost.conf index d39f3f7d..95f8211f 100644 --- a/library/roles/nextcloud/templates/nginx-virthost.conf +++ b/library/roles/nextcloud/templates/nginx-virthost.conf @@ -21,8 +21,8 @@ server { } server { - listen 443 ssl http2; - listen [::]:443 ssl http2; + listen 443 ssl; + listen [::]:443 ssl; server_name {{ item.nginx_servername }}; include /etc/nginx/snippets/nginx-server-ssl.conf; @@ -31,7 +31,7 @@ server { # 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; + add_header Strict-Transport-Security "max-age=15768000"; # includeSubDomains; preload;"; # # WARNING: Only add the preload option once you read about @@ -39,11 +39,16 @@ server { # 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 X-Content-Type-Options nosniff; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Robots-Tag none; - add_header X-Download-Options noopen; - add_header X-Permitted-Cross-Domain-Policies none; + 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 {{ item.doc_root }}; @@ -88,18 +93,19 @@ server { #pagespeed off; location / { - rewrite ^ /index.php$uri; + rewrite ^ /index.php; } - location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ { + location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ { deny all; } - location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { + location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) { deny all; } location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) { fastcgi_split_path_info ^(.+\.php)(/.*)$; + try_files $fastcgi_script_name =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; @@ -119,8 +125,8 @@ server { # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block - location ~ \.(?:css|js|woff|svg|gif)$ { - try_files $uri /index.php$uri$is_args$args; + location ~ \.(?:css|js|woff|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) @@ -133,17 +139,20 @@ server { # 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 X-Content-Type-Options nosniff; - add_header X-XSS-Protection "1; mode=block"; - add_header X-Robots-Tag none; - add_header X-Download-Options noopen; - add_header X-Permitted-Cross-Domain-Policies none; + 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)$ { - try_files $uri /index.php$uri$is_args$args; + location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ { + try_files $uri /index.php$request_uri; # Optional: Don't log access to other assets access_log off; }