Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
NoCloud
docker
Nextcloud
Commits
01fef607
Verified
Commit
01fef607
authored
1 year ago
by
David Beniamine
Browse files
Options
Downloads
Patches
Plain Diff
Update for NC 28
parent
41e5550a
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
docker-compose.yml
+2
-2
2 additions, 2 deletions
docker-compose.yml
nginx.conf.sample
+204
-132
204 additions, 132 deletions
nginx.conf.sample
traefik.yml
+5
-4
5 additions, 4 deletions
traefik.yml
with
211 additions
and
138 deletions
docker-compose.yml
+
2
−
2
View file @
01fef607
...
@@ -3,7 +3,7 @@ services:
...
@@ -3,7 +3,7 @@ services:
nextcloud
:
nextcloud
:
container_name
:
nextcloud-server
container_name
:
nextcloud-server
image
:
nextcloud:2
2
-fpm
image
:
nextcloud:2
8
-fpm
stdin_open
:
true
stdin_open
:
true
tty
:
true
tty
:
true
restart
:
always
restart
:
always
...
@@ -20,7 +20,7 @@ services:
...
@@ -20,7 +20,7 @@ services:
cron
:
cron
:
container_name
:
cron
container_name
:
cron
image
:
nextcloud:2
1
-fpm
image
:
nextcloud:2
8
-fpm
restart
:
always
restart
:
always
volumes
:
volumes
:
-
app_data:/var/www/html
-
app_data:/var/www/html
...
...
This diff is collapsed.
Click to expand it.
nginx.conf.sample
+
204
−
132
View file @
01fef607
...
@@ -14,7 +14,11 @@ http {
...
@@ -14,7 +14,11 @@ http {
server nextcloud-server:9000;
server nextcloud-server:9000;
}
}
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
map $arg_v $asset_immutable {
"" "";
default ", immutable";
}
include /etc/nginx/mime.types;
include /etc/nginx/mime.types;
default_type application/octet-stream;
default_type application/octet-stream;
...
@@ -44,28 +48,82 @@ http {
...
@@ -44,28 +48,82 @@ http {
"" $this_host;
"" $this_host;
}
}
server {
server {
listen 80;
listen 80;
# Prevent nginx HTTP Server Detection
server_tokens off;
# 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;
# set max upload size and increase upload timeout:
client_max_body_size 10G;
client_body_timeout 300s;
fastcgi_buffers 64 4K;
# Add headers to serve security related headers
# 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;
# 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 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
Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"
;
add_header
X-Content-Type-Options "nosniff" always
;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options nosniff;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag "noindex, nofollow" always;
add_header X-Robots-Tag none;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
# Remove X-Powered-By, which is an information leak
fastcgi_hide_header X-Powered-By;
# 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:
include mime.types;
types {
text/javascript js mjs;
application/wasm wasm;
}
root /var/www/html;
root /var/www/html;
client_max_body_size 10G; # 0=unlimited - set max upload size
fastcgi_buffers 64 4K;
gzip off;
# Specify how to handle directories -- specifying `/index.php$request_uri`
# here as the fallback means that Nginx always exhibits the desired behaviour
index index.php;
# when a client requests a path that corresponds to a directory that exists
error_page 403 /core/templates/403.php;
# on the server. In particular, if that directory contains an index.php file,
error_page 404 /core/templates/404.php;
# 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;
...
@@ -73,72 +131,86 @@ http {
...
@@ -73,72 +131,86 @@ http {
access_log off;
access_log off;
}
}
location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ {
# Make a regex exception for `/.well-known` so that clients can still
deny all;
# 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 ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
location = /.well-known/carddav { return 301 /remote.php/dav/; }
deny all;
location = /.well-known/caldav { return 301 /remote.php/dav/; }
}
location / {
location /.well-known/acme-challenge { try_files $uri $uri/ =404; }
rewrite ^/remote/(.*) /remote.php last;
location /.well-known/pki-validation { try_files $uri $uri/ =404; }
rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
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;
}
}
# Uncomment the block below to use onlyoffice
# Rules borrowed from `.htaccess` to hide certain paths from clients
#location ~* ^/ds-vpath/ {
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
# rewrite /ds-vpath/(.*) /$1 break;
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
# proxy_pass http://onlyoffice-document-server;
# proxy_redirect off;
# client_max_body_size 100m;
# 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\/proxy) /index.php$request_uri;
# proxy_http_version 1.1;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
# proxy_set_header Upgrade $http_upgrade;
set $path_info $fastcgi_path_info;
# # Disabled, if enable we get "Unknown error on OnlyOffice
# # proxy_set_header Connection "upgrade";
# proxy_set_header Host $http_host;
try_files $fastcgi_script_name =404;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header X-Forwarded-Host $the_host/ds-vpath;
# # Manually set to https to avoid "Unknown error" on OnlyOffice
# proxy_set_header X-Forwarded-Proto "https";
#}
location ~ \.php(?:$|/) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS off;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
fastcgi_param front_controller_active true; # Enable pretty urls
fastcgi_pass backend;
fastcgi_pass backend;
fastcgi_intercept_errors on;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
fastcgi_max_temp_file_size 0;
}
}
# Adding the cache control header for js and css files
# Serve static files
# Make sure it is BELOW the location ~ \.php(?:$|/) { block
location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
location ~* \.(?:css|js)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=7200";
# HTTP response headers borrowed from Nextcloud `.htaccess`
# Add headers to serve security related headers
add_header Cache-Control "public, max-age=15778463$asset_immutable";
add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options nosniff;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block";
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag none;
add_header X-Robots-Tag "noindex, nofollow" always;
add_header X-Download-Options noopen;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Permitted-Cross-Domain-Policies none;
access_log off; # Optional: Don't log access to assets
# Optional: Don't log access to assets
access_log off;
}
}
# Optional: Don't log access to other assets
location ~ \.woff2?$ {
location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
try_files $uri /index.php$request_uri;
access_log off;
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;
}
}
}
}
}
This diff is collapsed.
Click to expand it.
traefik.yml
+
5
−
4
View file @
01fef607
...
@@ -11,10 +11,11 @@ services:
...
@@ -11,10 +11,11 @@ services:
-
"
traefik.http.routers.nextcloud.rule=Host(`${HOST}`)"
-
"
traefik.http.routers.nextcloud.rule=Host(`${HOST}`)"
-
"
traefik.http.routers.nextcloud.tls.certresolver=myresolver"
-
"
traefik.http.routers.nextcloud.tls.certresolver=myresolver"
-
"
traefik.http.routers.nextcloud.entrypoints=web,websecure"
-
"
traefik.http.routers.nextcloud.entrypoints=web,websecure"
-
"
traefik.http.routers.nextcloud.middlewares=nextcloud-caldav@docker,hardening@docker"
-
"
traefik.http.routers.nextcloud.middlewares=hardening@docker,nextcloud_redirectregex"
-
"
traefik.http.middlewares.nextcloud-caldav.redirectregex.permanent=true"
-
"
traefik.http.middlewares.nextcloud_redirectregex.redirectregex.permanent=true"
-
"
traefik.http.middlewares.nextcloud-caldav.redirectregex.regex=^https://(.*)/.well-known/(card|cal)dav"
-
"
traefik.http.middlewares.nextcloud_redirectregex.redirectregex.regex=https://(.*)/.well-known/(?:card|cal)dav"
-
"
traefik.http.middlewares.nextcloud-caldav.redirectregex.replacement=https://$${1}/remote.php/dav/"
-
"
traefik.http.middlewares.nextcloud_redirectregex.redirectregex.replacement=https://$${1}/remote.php/dav"
networks
:
networks
:
traefik
:
traefik
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment