diff --git a/.examples/docker-compose/with-nginx-proxy/apache/app/redis.php b/.examples/docker-compose/with-nginx-proxy/apache/app/redis.php deleted file mode 100644 index 9f8b5d2..0000000 --- a/.examples/docker-compose/with-nginx-proxy/apache/app/redis.php +++ /dev/null @@ -1,11 +0,0 @@ - '\\OC\\Memcache\\Redis', - 'filelocking.enabled' => 'true', - 'redis' => - array ( - 'host' => 'redis', - 'port' => 6379, - ), -); -?> diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/app/redis.php b/.examples/docker-compose/with-nginx-proxy/fpm/app/redis.php deleted file mode 100644 index 9f8b5d2..0000000 --- a/.examples/docker-compose/with-nginx-proxy/fpm/app/redis.php +++ /dev/null @@ -1,11 +0,0 @@ - '\\OC\\Memcache\\Redis', - 'filelocking.enabled' => 'true', - 'redis' => - array ( - 'host' => 'redis', - 'port' => 6379, - ), -); -?> diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/web/nginx.conf b/.examples/docker-compose/with-nginx-proxy/fpm/web/nginx.conf deleted file mode 100644 index 40b0975..0000000 --- a/.examples/docker-compose/with-nginx-proxy/fpm/web/nginx.conf +++ /dev/null @@ -1,110 +0,0 @@ -user www-data; - -events { - worker_connections 768; -} - -http { - upstream backend { - server app:9000; - } - include /etc/nginx/mime.types; - default_type application/octet-stream; - - server { - listen 80; - - # Add headers to serve security related headers - add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; - 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; - - root /var/www/html; - client_max_body_size 10G; # 0=unlimited - set max upload size - fastcgi_buffers 64 4K; - - gzip off; - - index index.php; - error_page 403 /core/templates/403.php; - error_page 404 /core/templates/404.php; - - rewrite ^/.well-known/carddav /remote.php/dav/ permanent; - rewrite ^/.well-known/caldav /remote.php/dav/ permanent; - - location = /robots.txt { - allow all; - log_not_found off; - access_log off; - } - - location ~ ^/(build|tests|config|lib|3rdparty|templates|data)/ { - deny all; - } - - location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { - deny all; - } - - location / { - rewrite ^/remote/(.*) /remote.php last; - rewrite ^(/core/doc/[^\/]+/)$ $1/index.html; - try_files $uri $uri/ =404; - } - - location ~ \.php(?:$|/) { - fastcgi_split_path_info ^(.+\.php)(/.+)$; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; - fastcgi_param PATH_INFO $fastcgi_path_info; - fastcgi_param HTTPS on; - fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice - fastcgi_pass backend; - fastcgi_intercept_errors on; - } - - # Adding the cache control header for js and css files - # Make sure it is BELOW the location ~ \.php(?:$|/) { block - location ~* \.(?:css|js)$ { - add_header Cache-Control "public, max-age=7200"; - # Add headers to serve security related headers - add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; - add_header X-Content-Type-Options nosniff; - add_header X-Frame-Options "SAMEORIGIN"; - 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; - # Optional: Don't log access to assets - access_log off; - } - - # Optional: Don't log access to other assets - location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|swf)$ { - access_log off; - } - - # collabora static files - location ^~ /loleaflet { - proxy_pass https://collabora:9980; - proxy_set_header Host $http_host; - } - - # collabora WOPI discovery URL - location ^~ /hosting/discovery { - proxy_pass https://collabora:9980; - proxy_set_header Host $http_host; - } - - # collabora websockets, download, presentation and image upload - location ^~ /lool { - proxy_pass https://collabora:9980; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $http_host; - } - } -} diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/Dockerfile b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/Dockerfile new file mode 100644 index 0000000..00598dd --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/Dockerfile @@ -0,0 +1,5 @@ +FROM nextcloud:apache + +COPY autoconfig.php /usr/src/nextcloud/config/autoconfig.php + +COPY redis.config.php /usr/src/nextcloud/config/redis.config.php diff --git a/.examples/docker-compose/with-nginx-proxy/apache/app/autoconfig.php b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/autoconfig.php similarity index 100% rename from .examples/docker-compose/with-nginx-proxy/apache/app/autoconfig.php rename to .examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/autoconfig.php diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/redis.config.php b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/redis.config.php new file mode 100644 index 0000000..b0cebe3 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/redis.config.php @@ -0,0 +1,8 @@ + '\OC\Memcache\Redis', + 'redis' => array( + 'host' => 'redis', + 'port' => 6379, + ), +); diff --git a/.examples/docker-compose/with-nginx-proxy/apache/db.env b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/db.env similarity index 100% rename from .examples/docker-compose/with-nginx-proxy/apache/db.env rename to .examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/db.env diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml new file mode 100644 index 0000000..80e3299 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml @@ -0,0 +1,100 @@ +version: '3' + +services: + db: + image: mariadb + # image: mysql + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD= + env_file: + - db.env + + redis: + image: redis + restart: always + + app: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + environment: + - VIRTUAL_HOST= + - LETSENCRYPT_HOST= + - LETSENCRYPT_EMAIL= + env_file: + - db.env + depends_on: + - db + - redis + networks: + - proxy-tier + - default + + cron: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + user: www-data + entrypoint: | + bash -c 'bash -s < '\OC\Memcache\Redis', + 'redis' => array( + 'host' => 'redis', + 'port' => 6379, + ), +); diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/db.env b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/db.env similarity index 100% rename from .examples/docker-compose/with-nginx-proxy/fpm/db.env rename to .examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/db.env diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml new file mode 100644 index 0000000..e1c3a17 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml @@ -0,0 +1,108 @@ +version: '3' + +services: + db: + image: mariadb + # image: mysql + restart: always + volumes: + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD= + env_file: + - db.env + + redis: + image: redis + restart: always + + app: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + env_file: + - db.env + depends_on: + - db + - redis + + web: + build: ./web + restart: always + volumes: + - nextcloud:/var/www/html:ro + environment: + - VIRTUAL_HOST= + - LETSENCRYPT_HOST= + - LETSENCRYPT_EMAIL= + depends_on: + - app + networks: + - proxy-tier + - default + + cron: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + user: www-data + entrypoint: | + bash -c 'bash -s < '/var/www/html/data', + 'dbtype' => 'mysql', + 'dbname' => getenv('MYSQL_DATABASE'), + 'dbuser' => getenv('MYSQL_USER'), + 'dbpass' => getenv('MYSQL_PASSWORD'), + 'dbhost' => 'db', + 'dbtableprefix' => '', +); diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/apache/db.env b/.examples/docker-compose/with-nginx-proxy/mariadb/apache/db.env new file mode 100644 index 0000000..a436605 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/apache/db.env @@ -0,0 +1,3 @@ +MYSQL_PASSWORD= +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud diff --git a/.examples/docker-compose/with-nginx-proxy/apache/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/mariadb/apache/docker-compose.yml similarity index 78% rename from .examples/docker-compose/with-nginx-proxy/apache/docker-compose.yml rename to .examples/docker-compose/with-nginx-proxy/mariadb/apache/docker-compose.yml index ab55024..264a9ed 100644 --- a/.examples/docker-compose/with-nginx-proxy/apache/docker-compose.yml +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/apache/docker-compose.yml @@ -1,79 +1,72 @@ version: '3' -volumes: - certs: - conf.d: - vhost.d: - html: - nextcloud: - db: - -networks: - proxy-tier: - services: - proxy: - build: proxy - ports: - - 80:80 - - 443:443 - volumes: - - conf.d:/etc/nginx/conf.d - - vhost.d:/etc/nginx/vhost.d - - html:/usr/share/nginx/html - - certs:/etc/nginx/certs:ro - - /var/run/docker.sock:/tmp/docker.sock:ro - networks: - - proxy-tier - labels: - - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy - restart: always - - letsencrypt-companion: - image: jrcs/letsencrypt-nginx-proxy-companion - volumes: - - conf.d:/etc/nginx/conf.d - - vhost.d:/etc/nginx/vhost.d - - html:/usr/share/nginx/html - - certs:/etc/nginx/certs:rw - - /var/run/docker.sock:/var/run/docker.sock:ro - networks: - - proxy-tier - restart: always - - app: - build: app - volumes: - - nextcloud:/var/www/html - env_file: - - db.env - environment: - - VIRTUAL_HOST= - - LETSENCRYPT_HOST= - - LETSENCRYPT_EMAIL= - networks: - - proxy-tier - - default - restart: always - db: image: mariadb + # image: mysql + restart: always volumes: - db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD= env_file: - db.env - restart: always - redis: - image: redis + app: + build: ./app restart: always - - collabora: - image: collabora/code - cap_add: - - MKNOD + volumes: + - nextcloud:/var/www/html environment: - - domain= + - VIRTUAL_HOST= + - LETSENCRYPT_HOST= + - LETSENCRYPT_EMAIL= + env_file: + - db.env + depends_on: + - db + networks: + - proxy-tier + - default + + proxy: + build: ./proxy restart: always + ports: + - 80:80 + - 443:443 + labels: + com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true" + volumes: + - certs:/etc/nginx/certs:ro + - conf.d:/etc/nginx/conf.d + - vhost.d:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - /var/run/docker.sock:/tmp/docker.sock:ro + networks: + - proxy-tier + + letsencrypt-companion: + image: jrcs/letsencrypt-nginx-proxy-companion + restart: always + volumes: + - certs:/etc/nginx/certs + - conf.d:/etc/nginx/conf.d + - vhost.d:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - /var/run/docker.sock:/var/run/docker.sock:ro + networks: + - proxy-tier + depends_on: + - proxy + +volumes: + db: + nextcloud: + certs: + conf.d: + vhost.d: + html: + +networks: + proxy-tier: diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/apache/proxy/Dockerfile b/.examples/docker-compose/with-nginx-proxy/mariadb/apache/proxy/Dockerfile new file mode 100644 index 0000000..242c84e --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/apache/proxy/Dockerfile @@ -0,0 +1,3 @@ +FROM jwilder/nginx-proxy:alpine + +COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/apache/proxy/uploadsize.conf b/.examples/docker-compose/with-nginx-proxy/mariadb/apache/proxy/uploadsize.conf new file mode 100644 index 0000000..8c1bc58 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/apache/proxy/uploadsize.conf @@ -0,0 +1 @@ +client_max_body_size 10g; diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/app/Dockerfile b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/app/Dockerfile similarity index 61% rename from .examples/docker-compose/with-nginx-proxy/fpm/app/Dockerfile rename to .examples/docker-compose/with-nginx-proxy/mariadb/fpm/app/Dockerfile index dfd3c8c..d1d1f80 100644 --- a/.examples/docker-compose/with-nginx-proxy/fpm/app/Dockerfile +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/app/Dockerfile @@ -1,4 +1,3 @@ FROM nextcloud:fpm COPY autoconfig.php /usr/src/nextcloud/config/autoconfig.php -COPY redis.php /usr/src/nextcloud/config/redis.php diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/app/autoconfig.php b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/app/autoconfig.php new file mode 100644 index 0000000..ea7004e --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/app/autoconfig.php @@ -0,0 +1,10 @@ + '/var/www/html/data', + 'dbtype' => 'mysql', + 'dbname' => getenv('MYSQL_DATABASE'), + 'dbuser' => getenv('MYSQL_USER'), + 'dbpass' => getenv('MYSQL_PASSWORD'), + 'dbhost' => 'db', + 'dbtableprefix' => '', +); diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/db.env b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/db.env new file mode 100644 index 0000000..a436605 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/db.env @@ -0,0 +1,3 @@ +MYSQL_PASSWORD= +MYSQL_DATABASE=nextcloud +MYSQL_USER=nextcloud diff --git a/.examples/docker-compose/with-nginx-proxy/fpm/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/docker-compose.yml similarity index 76% rename from .examples/docker-compose/with-nginx-proxy/fpm/docker-compose.yml rename to .examples/docker-compose/with-nginx-proxy/mariadb/fpm/docker-compose.yml index bbe5ec3..35cdd33 100644 --- a/.examples/docker-compose/with-nginx-proxy/fpm/docker-compose.yml +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/docker-compose.yml @@ -1,85 +1,80 @@ version: '3' -volumes: - certs: - conf.d: - vhost.d: - html: - nextcloud: - db: - -networks: - proxy-tier: - services: - proxy: - build: proxy - ports: - - 80:80 - - 443:443 - volumes: - - conf.d:/etc/nginx/conf.d - - vhost.d:/etc/nginx/vhost.d - - html:/usr/share/nginx/html - - certs:/etc/nginx/certs:ro - - /var/run/docker.sock:/tmp/docker.sock:ro - networks: - - proxy-tier - labels: - - com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy + db: + image: mariadb + # image: mysql restart: always - - letsencrypt-companion: - image: jrcs/letsencrypt-nginx-proxy-companion volumes: - - conf.d:/etc/nginx/conf.d - - vhost.d:/etc/nginx/vhost.d - - html:/usr/share/nginx/html - - certs:/etc/nginx/certs:rw - - /var/run/docker.sock:/var/run/docker.sock:ro - networks: - - proxy-tier - restart: always + - db:/var/lib/mysql + environment: + - MYSQL_ROOT_PASSWORD= + env_file: + - db.env - web: - build: web + app: + build: ./app + restart: always volumes: - nextcloud:/var/www/html + env_file: + - db.env + depends_on: + - db + + web: + build: ./web + restart: always + volumes: + - nextcloud:/var/www/html:ro environment: - VIRTUAL_HOST= - LETSENCRYPT_HOST= - LETSENCRYPT_EMAIL= + depends_on: + - app networks: - proxy-tier - default - restart: always - app: - build: app - env_file: - - db.env + proxy: + build: ./proxy + restart: always + ports: + - 80:80 + - 443:443 + labels: + com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true" volumes: - - nextcloud:/var/www/html - restart: always + - certs:/etc/nginx/certs:ro + - conf.d:/etc/nginx/conf.d + - vhost.d:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - /var/run/docker.sock:/tmp/docker.sock:ro + networks: + - proxy-tier + letsencrypt-companion: + image: jrcs/letsencrypt-nginx-proxy-companion + restart: always + volumes: + - certs:/etc/nginx/certs + - conf.d:/etc/nginx/conf.d + - vhost.d:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - /var/run/docker.sock:/var/run/docker.sock:ro + networks: + - proxy-tier + depends_on: + - proxy + +volumes: db: - image: mariadb - volumes: - - db:/var/lib/mysql - env_file: - - db.env - environment: - - MYSQL_ROOT_PASSWORD= - restart: always + nextcloud: + certs: + conf.d: + vhost.d: + html: - redis: - image: redis - restart: always - - collabora: - image: collabora/code - cap_add: - - MKNOD - environment: - - domain= - restart: always +networks: + proxy-tier: diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/Dockerfile b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/Dockerfile new file mode 100644 index 0000000..242c84e --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/Dockerfile @@ -0,0 +1,3 @@ +FROM jwilder/nginx-proxy:alpine + +COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/uploadsize.conf b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/uploadsize.conf new file mode 100644 index 0000000..8c1bc58 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/uploadsize.conf @@ -0,0 +1 @@ +client_max_body_size 10g; diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/Dockerfile b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/Dockerfile new file mode 100644 index 0000000..d6eac3e --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx + +COPY nginx.conf /etc/nginx/nginx.conf diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf new file mode 100644 index 0000000..c23a770 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf @@ -0,0 +1,154 @@ +user www-data; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + upstream php-handler { + server app:9000; + } + + 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;"; + # + # 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 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; + + 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; + + location = /.well-known/carddav { + return 301 $scheme://$host/remote.php/dav; + } + location = /.well-known/caldav { + return 301 $scheme://$host/remote.php/dav; + } + + # set max upload size + client_max_body_size 512M; + fastcgi_buffers 64 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$uri; + } + + 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/.+|ocs-provider/.+)\.php(?:$|/) { + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + # fastcgi_param HTTPS on; + #Avoid sending the security headers twice + fastcgi_param modHeadersAvailable true; + fastcgi_param front_controller_active true; + fastcgi_pass php-handler; + fastcgi_intercept_errors on; + fastcgi_request_buffering off; + } + + location ~ ^/(?:updater|ocs-provider)(?:$|/) { + try_files $uri/ =404; + index index.php; + } + + # 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; + 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;"; + # + # 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 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; + # 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; + # Optional: Don't log access to other assets + access_log off; + } + } + +} diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/apache/app/Dockerfile b/.examples/docker-compose/with-nginx-proxy/postgres/apache/app/Dockerfile new file mode 100644 index 0000000..8c03a7c --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/apache/app/Dockerfile @@ -0,0 +1,3 @@ +FROM nextcloud:apache + +COPY autoconfig.php /usr/src/nextcloud/config/autoconfig.php diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/apache/app/autoconfig.php b/.examples/docker-compose/with-nginx-proxy/postgres/apache/app/autoconfig.php new file mode 100644 index 0000000..3ac9f94 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/apache/app/autoconfig.php @@ -0,0 +1,10 @@ + '/var/www/html/data', + 'dbtype' => 'pgsql', + 'dbname' => getenv('POSTGRES_DB'), + 'dbuser' => getenv('POSTGRES_USER'), + 'dbpass' => getenv('POSTGRES_PASSWORD'), + 'dbhost' => 'db', + 'dbtableprefix' => '', +); diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/apache/db.env b/.examples/docker-compose/with-nginx-proxy/postgres/apache/db.env new file mode 100644 index 0000000..41106ca --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/apache/db.env @@ -0,0 +1,3 @@ +POSTGRES_PASSWORD= +POSTGRES_DB=nextcloud +POSTGRES_USER=nextcloud diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/apache/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/postgres/apache/docker-compose.yml new file mode 100644 index 0000000..c1a992d --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/apache/docker-compose.yml @@ -0,0 +1,69 @@ +version: '3' + +services: + db: + image: postgres + restart: always + volumes: + - db:/var/lib/postgresql/data + env_file: + - db.env + + app: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + environment: + - VIRTUAL_HOST= + - LETSENCRYPT_HOST= + - LETSENCRYPT_EMAIL= + env_file: + - db.env + depends_on: + - db + networks: + - proxy-tier + - default + + proxy: + build: ./proxy + restart: always + ports: + - 80:80 + - 443:443 + labels: + com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true" + volumes: + - certs:/etc/nginx/certs:ro + - conf.d:/etc/nginx/conf.d + - vhost.d:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - /var/run/docker.sock:/tmp/docker.sock:ro + networks: + - proxy-tier + + letsencrypt-companion: + image: jrcs/letsencrypt-nginx-proxy-companion + restart: always + volumes: + - certs:/etc/nginx/certs + - conf.d:/etc/nginx/conf.d + - vhost.d:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - /var/run/docker.sock:/var/run/docker.sock:ro + networks: + - proxy-tier + depends_on: + - proxy + +volumes: + db: + nextcloud: + certs: + conf.d: + vhost.d: + html: + +networks: + proxy-tier: diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/apache/proxy/Dockerfile b/.examples/docker-compose/with-nginx-proxy/postgres/apache/proxy/Dockerfile new file mode 100644 index 0000000..242c84e --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/apache/proxy/Dockerfile @@ -0,0 +1,3 @@ +FROM jwilder/nginx-proxy:alpine + +COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/apache/proxy/uploadsize.conf b/.examples/docker-compose/with-nginx-proxy/postgres/apache/proxy/uploadsize.conf new file mode 100644 index 0000000..8c1bc58 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/apache/proxy/uploadsize.conf @@ -0,0 +1 @@ +client_max_body_size 10g; diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/app/Dockerfile b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/app/Dockerfile new file mode 100644 index 0000000..d1d1f80 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/app/Dockerfile @@ -0,0 +1,3 @@ +FROM nextcloud:fpm + +COPY autoconfig.php /usr/src/nextcloud/config/autoconfig.php diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/app/autoconfig.php b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/app/autoconfig.php new file mode 100644 index 0000000..3ac9f94 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/app/autoconfig.php @@ -0,0 +1,10 @@ + '/var/www/html/data', + 'dbtype' => 'pgsql', + 'dbname' => getenv('POSTGRES_DB'), + 'dbuser' => getenv('POSTGRES_USER'), + 'dbpass' => getenv('POSTGRES_PASSWORD'), + 'dbhost' => 'db', + 'dbtableprefix' => '', +); diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/db.env b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/db.env new file mode 100644 index 0000000..41106ca --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/db.env @@ -0,0 +1,3 @@ +POSTGRES_PASSWORD= +POSTGRES_DB=nextcloud +POSTGRES_USER=nextcloud diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/docker-compose.yml new file mode 100644 index 0000000..117f8e7 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/docker-compose.yml @@ -0,0 +1,78 @@ +version: '3' + +services: + db: + image: postgres + restart: always + volumes: + - db:/var/lib/postgresql/data + env_file: + - db.env + + app: + build: ./app + restart: always + volumes: + - nextcloud:/var/www/html + env_file: + - db.env + depends_on: + - db + + web: + build: ./web + restart: always + volumes: + - nextcloud:/var/www/html:ro + environment: + - VIRTUAL_HOST= + - LETSENCRYPT_HOST= + - LETSENCRYPT_EMAIL= + depends_on: + - app + networks: + - proxy-tier + - default + + proxy: + build: ./proxy + restart: always + ports: + - 80:80 + - 443:443 + labels: + com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy: "true" + volumes: + - certs:/etc/nginx/certs:ro + - conf.d:/etc/nginx/conf.d + - vhost.d:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - /var/run/docker.sock:/tmp/docker.sock:ro + networks: + - proxy-tier + + letsencrypt-companion: + image: jrcs/letsencrypt-nginx-proxy-companion + restart: always + volumes: + - certs:/etc/nginx/certs + - conf.d:/etc/nginx/conf.d + - vhost.d:/etc/nginx/vhost.d + - html:/usr/share/nginx/html + - /var/run/docker.sock:/var/run/docker.sock:ro + networks: + - proxy-tier + depends_on: + - proxy + +volumes: + db: + nextcloud: + certs: + conf.d: + vhost.d: + html: + +networks: + proxy-tier: + diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/proxy/Dockerfile b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/proxy/Dockerfile new file mode 100644 index 0000000..242c84e --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/proxy/Dockerfile @@ -0,0 +1,3 @@ +FROM jwilder/nginx-proxy:alpine + +COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/proxy/uploadsize.conf b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/proxy/uploadsize.conf new file mode 100644 index 0000000..8c1bc58 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/proxy/uploadsize.conf @@ -0,0 +1 @@ +client_max_body_size 10g; diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/Dockerfile b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/Dockerfile new file mode 100644 index 0000000..d6eac3e --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/Dockerfile @@ -0,0 +1,3 @@ +FROM nginx + +COPY nginx.conf /etc/nginx/nginx.conf diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf new file mode 100644 index 0000000..c23a770 --- /dev/null +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf @@ -0,0 +1,154 @@ +user www-data; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + #tcp_nopush on; + + keepalive_timeout 65; + + #gzip on; + + upstream php-handler { + server app:9000; + } + + 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;"; + # + # 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 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; + + 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; + + location = /.well-known/carddav { + return 301 $scheme://$host/remote.php/dav; + } + location = /.well-known/caldav { + return 301 $scheme://$host/remote.php/dav; + } + + # set max upload size + client_max_body_size 512M; + fastcgi_buffers 64 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$uri; + } + + 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/.+|ocs-provider/.+)\.php(?:$|/) { + fastcgi_split_path_info ^(.+\.php)(/.*)$; + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $fastcgi_path_info; + # fastcgi_param HTTPS on; + #Avoid sending the security headers twice + fastcgi_param modHeadersAvailable true; + fastcgi_param front_controller_active true; + fastcgi_pass php-handler; + fastcgi_intercept_errors on; + fastcgi_request_buffering off; + } + + location ~ ^/(?:updater|ocs-provider)(?:$|/) { + try_files $uri/ =404; + index index.php; + } + + # 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; + 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;"; + # + # 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 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; + # 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; + # Optional: Don't log access to other assets + access_log off; + } + } + +}