Compare commits

..
96 Commits
Author SHA1 Message Date
Mike Holloway 3046f45b11 podman-compose - acme-companion 2025-12-10 02:48:09 -05:00
Mike Holloway 5d984b63d9 Basic ReadMe 2025-12-09 21:40:49 -05:00
Mike Holloway 2c8417771d redis,cron - hostnames for resolution to resolve redis connection errors in data/nextcloud.log 2025-12-09 20:59:54 -05:00
Mike Holloway a92b993be6 app,db - default postgres user 2025-12-09 20:11:03 -05:00
Mike Holloway 812d8ff158 app,db - env variables for automated install 2025-12-09 19:06:41 -05:00
Mike Holloway 117f43dc41 db - add to podman network for name resolution 2025-12-09 18:55:46 -05:00
Mike Holloway 31665244ad Working curl response - web container 2025-12-09 18:26:24 -05:00
Mike Holloway 579302d310 Working curl response 2025-12-09 18:21:55 -05:00
Mike Holloway 0155c77319 podman-compose - db.env template, no force overwrite 2025-12-09 17:47:07 -05:00
Mike Holloway 17cb5dfa44 podman-compose - db.env template 2025-12-09 17:21:11 -05:00
Mike Holloway 71489a12b6 web - unsaved file. podman-compose - image key 2025-12-09 17:06:06 -05:00
Mike Holloway 6387bd8bff podman - network names, images 2025-12-09 17:01:01 -05:00
Mike Holloway 53dc2c99e3 proxy - user.name loop var 2025-12-09 16:54:22 -05:00
Mike Holloway 6c6c09421c proxy - web subdir 2025-12-09 16:44:45 -05:00
Mike Holloway c2b3fe960a Return to nextcloud repo example 2025-12-09 16:42:05 -05:00
Mike Holloway f5fce9b37e php - volume path 2025-12-09 03:46:37 -05:00
Mike Holloway b859e97294 nginx - server_name for 301 redirect 2025-12-09 02:45:41 -05:00
Mike Holloway 8cc4e49eb9 nginx - 80 and 443 inside container, to match docker-compose.yml 2025-12-08 23:45:05 -05:00
Mike Holloway a161b2d63e nginx - debug log level 2025-12-07 22:40:34 -05:00
Mike Holloway 884d325009 nginx - debug log level 2025-12-07 20:08:16 -05:00
Mike Holloway 911a6b5105 nginx - map directive in supplementary conf file along with invocation 2025-12-07 18:38:38 -05:00
Mike Holloway 4217f56c49 nginx - map directive troubleshooting 2025-12-07 18:28:00 -05:00
Mike Holloway 8060227475 nginx - Add asset_immutable var from nextcloud fpm example 2025-12-07 18:18:52 -05:00
Mike Holloway 39a5ca3f9a nginx - Dockerfile sed -i, semicolon line terminators 2025-12-07 18:13:32 -05:00
Mike Holloway c0af475117 nginx test 2025-12-07 18:03:30 -05:00
Mike Holloway 508c796abc nginx test 2025-12-07 18:01:07 -05:00
Mike Holloway b843fc68af nginx test 2025-12-07 17:55:06 -05:00
Mike Holloway bebfcca19f files.yml 2025-12-07 12:51:08 -05:00
Mike Holloway fee7347015 Without nginx-proxy 2025-12-07 12:48:37 -05:00
Mike Holloway e7d852842e proxy files work 2025-12-07 10:51:23 -05:00
Mike Holloway 5c78faa68f proxy files work 2025-12-07 02:34:23 -05:00
Mike Holloway 3791c6978c proxy files work 2025-12-07 02:31:30 -05:00
Mike Holloway 1d9f848b35 proxy files work 2025-12-07 02:26:46 -05:00
Mike Holloway 5ade913160 proxy files work 2025-12-07 02:22:13 -05:00
Mike Holloway 5828cdd570 proxy files work 2025-12-07 02:20:26 -05:00
Mike Holloway da62290e32 fastcgi proto 2025-12-07 02:12:28 -05:00
Mike Holloway 94db1a0f5b vhost file loop 2025-12-07 01:59:12 -05:00
Mike Holloway 29f35c9036 location and vhost option separation 2025-12-07 01:55:03 -05:00
Mike Holloway c97defb361 vhost location file test 2025-12-07 01:46:17 -05:00
Mike Holloway e0244d52d9 vhost file name 2025-12-07 01:40:44 -05:00
Mike Holloway f191a60515 env vars quotation work 2025-12-07 01:28:50 -05:00
Mike Holloway 2a2cff230e env vars move 2025-12-07 01:22:28 -05:00
Mike Holloway deb1578587 vhost options, files not templates 2025-12-07 01:17:19 -05:00
Mike Holloway 5ac39bbcc8 vhost options 2025-12-07 00:51:25 -05:00
Mike Holloway 19f6fdab58 weboot change 2025-12-07 00:44:35 -05:00
Mike Holloway 6deaf3640d network changes 2025-12-07 00:29:59 -05:00
Mike Holloway e120c272eb podman network removal 2025-12-07 00:27:06 -05:00
Mike Holloway 1408e87b0c Adding nginx-proxy, db services 2025-12-07 00:23:40 -05:00
Mike Holloway 7795ef9605 Adding nginx-proxy, db services 2025-12-07 00:21:22 -05:00
Mike Holloway ec1ec82518 example ineffective with rootless, reworking 2025-12-07 00:10:59 -05:00
Mike Holloway 159488d1c2 example ineffective with rootless, reworking 2025-12-06 23:46:35 -05:00
Mike Holloway b9c4c19aec example ineffective with rootless, reworking 2025-12-06 23:41:49 -05:00
Mike Holloway 0c2cf683ef resolver removed, ineffective 2025-12-06 23:12:59 -05:00
Mike Holloway 3d1706b213 network_mode removed, ineffective 2025-12-06 23:08:39 -05:00
Mike Holloway 22eb713d4d networks and network_mode service level conflict part II 2025-12-06 22:09:34 -05:00
Mike Holloway c30423da60 networks and network_mode service level conflict 2025-12-06 21:47:33 -05:00
Mike Holloway 41f6ade6c2 add slirp4netns network_mode option 2025-12-06 21:30:19 -05:00
Mike Holloway cb329d73ef update hostname field 2025-12-06 21:06:13 -05:00
Mike Holloway 90d93777d8 default network is podman 2025-12-06 20:59:22 -05:00
Mike Holloway 3d71b98a1b nginx parent dir 2025-12-06 20:33:31 -05:00
Mike Holloway 869d20a78f Folder loop 2025-12-06 20:04:48 -05:00
Mike Holloway 80b42a89b6 user name rather than uid 2025-12-06 20:00:58 -05:00
Mike Holloway 2bf1bb469e Adding self-signed cert volume mounts 2025-12-06 19:47:32 -05:00
Mike Holloway 0a9cc4d76e Handle proxy container files, syntax fixes 2025-12-06 19:32:37 -05:00
Mike Holloway ada1c82e83 Handle proxy container files, syntax fixes 2025-12-06 19:30:02 -05:00
Mike Holloway ab13981028 Handle proxy container files 2025-12-06 18:25:03 -05:00
Mike Holloway fc0088e877 Add default network 2025-12-06 18:16:00 -05:00
Mike Holloway d729f860c3 Removed item var from conf j2 template file 2025-12-06 16:53:54 -05:00
Mike Holloway b8ac9849b6 ansible complains of undefined item - replacing template task with file task, syntax fix 2025-12-06 16:36:16 -05:00
Mike Holloway 62ed03d090 ansible complains of undefined item - replacing template task with file task, syntax fix 2025-12-06 16:33:06 -05:00
Mike Holloway cbedfeeab9 ansible complains of undefined item - replacing template task with file task 2025-12-06 16:30:13 -05:00
Mike Holloway 00f6fe0256 ansible complains of undefined item - replacing file called test in tasks/files.yml 2025-12-06 16:24:41 -05:00
Mike Holloway e3b29e100b ansible complains of undefined item - troubleshooting with empty file called test 2025-12-06 15:56:12 -05:00
Mike Holloway a77aa43613 ansible complains of undefined item - troubleshooting with empty file called test 2025-12-06 15:45:43 -05:00
Mike Holloway 0847131b66 ansible complains of undefined item - troubleshooting 2025-12-06 15:21:11 -05:00
Mike Holloway 21e1a4c4e4 ansible complains of undefined item - troubleshooting 2025-12-06 14:51:04 -05:00
Mike Holloway 63cbfd0bf7 Full reset of podman assets - rootless mods and env specific var values 2025-12-06 14:39:24 -05:00
Mike Holloway 2048b9aaea Full reset of podman assets - base example config from nextcloud fpm nginx proxy example 2025-12-06 12:02:05 -05:00
Mike Holloway 10bb24bbf6 nginx conf adjustments - virtual host necessity 2025-12-06 11:51:07 -05:00
Mike Holloway 981b6f2bcb web dir 2025-12-04 21:28:44 -05:00
Mike Holloway 12f564b694 web/nginx.conf placement, template 2025-12-04 20:44:39 -05:00
Mike Holloway 18ff83bef1 path fix 2025-12-04 20:21:03 -05:00
Mike Holloway e1b63a42ed web/nginx.conf placement 2025-12-04 20:16:34 -05:00
Mike Holloway f3fd68ef56 Env vars adjustment, hostname adjustment, env file adjustment 2025-12-04 19:26:40 -05:00
Mike Holloway 3fbf61f504 Add default network explicitly 2025-12-04 19:21:50 -05:00
Mike Holloway f343b26fe9 Using postgres fpm example from official git repo 2025-12-04 19:13:49 -05:00
Mike Holloway 7480b2e244 postgres env vars work 2025-12-03 23:22:08 -05:00
Mike Holloway 02a359709c postgres env vars work 2025-12-03 23:17:30 -05:00
Mike Holloway cea092ee6a static db name 2025-12-03 23:09:40 -05:00
Mike Holloway 1586beb003 testing variable concat for db name 2025-12-03 23:03:59 -05:00
Mike Holloway 4850b8e662 webserver env 2025-12-03 22:53:59 -05:00
Mike Holloway 55648892eb hostnames added 2025-12-03 22:46:28 -05:00
Mike Holloway b1324501b2 fastcgi_index parameter for nginx vhost.d conf 2025-12-03 22:25:44 -05:00
Mike Holloway 5a9a79ebf1 .db.env file 2025-12-03 22:18:10 -05:00
Mike Holloway 39f642775e vhosts.d 2025-12-03 21:58:18 -05:00
Mike Holloway dbd76e6059 template file 2025-12-03 21:55:22 -05:00
10 changed files with 420 additions and 87 deletions

No files matched your search

+45
View File
@@ -0,0 +1,45 @@
Role Name
=========
Produce a ready-to-configure nextcloud instance on the target system.
Requirements
------------
2025-12-09
- Rocky, AlmaLinux, or other RHEL-derived Linux system installation
- One internet-facing ethernet interface
Role Variables
--------------
host_vars:
certificates: 'self' || 'certbot'
service_users:
- name: nextcloud
services:
- "nextcloud"
Dependencies
------------
equilibrateit.podman_host
Example Playbook
----------------
Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
- hosts: servers
roles:
- { role: username.rolename, x: 42 }
License
-------
BSD-Clause-2
Author Information
------------------
An optional section for the role authors to include contact information, or a website (HTML is not allowed).
+4
View File
@@ -0,0 +1,4 @@
FROM nginx:latest
RUN sed -i 's/\#gzip.*on;/server_tokens\toff;\n #gzip\ton;/' /etc/nginx/nginx.conf && \
sed -i 's/^error_log.*;/error_log\t\/var\/log\/nginx\/error.log debug;/' /etc/nginx/nginx.conf
+1 -1
View File
@@ -1,6 +1,6 @@
- name: Check for certs
file:
path: "/home/nextcloud/nginx/certs/{{ item }}"
path: "/home/{{ user.name }}/proxy/certs/{{ item }}"
state: file
loop:
- "{{ inventory_hostname }}.key"
+8 -8
View File
@@ -1,14 +1,14 @@
- name: Create certbot certs
copy:
remote_src: true
src: "/etc/letsencrypt/live/nextcloud.equilibrateit.test/privkey.pem"
dest: "/home/nextcloud/nginx/certs/{{ inventory_hostname }}.key"
owner: 100999
group: 100999
src: "/etc/letsencrypt/live/{{ inventory_hostname }}/privkey.pem"
dest: "/home/{{ user.name }}/proxy/certs/{{ inventory_hostname }}.key"
owner: 100033
group: 100033
- copy:
remote_src: true
src: "/etc/letsencrypt/live/nextcloud.equilibrateit.test/fullchain.pem"
dest: "/home/nextcloud/nginx/certs/{{ inventory_hostname }}.crt"
owner: 100999
group: 100999
src: "/etc/letsencrypt/live/{{ inventory_hostname }}/fullchain.pem"
dest: "/home/{{ user.name }}/proxy/certs/{{ inventory_hostname }}.crt"
owner: 100033
group: 100033
+9 -9
View File
@@ -2,8 +2,8 @@
become: yes
become_user: nextcloud
command:
chdir: /home/nextcloud/
creates: "/home/nextcloud/{{ inventory_hostname }}.key"
chdir: /home/{{ user.name }}/
creates: "/home/{{ user.name }}/{{ inventory_hostname }}.key"
argv:
- openssl
- req
@@ -40,16 +40,16 @@
- copy:
src: "/home/nextcloud/{{ inventory_hostname }}.crt"
src: "/home/{{ user.name }}/{{ inventory_hostname }}.crt"
remote_src: true
dest: /home/nextcloud/nginx/certs/
owner: 100999
dest: /home/{{ user.name }}/proxy/certs/
owner: 100033
- copy:
src: "/home/nextcloud/{{ inventory_hostname }}.key"
src: "/home/{{ user.name }}/{{ inventory_hostname }}.key"
remote_src: true
dest: /home/nextcloud/nginx/certs/
owner: 100999
dest: /home/{{ user.name }}/proxy/certs/
owner: 100033
- file:
path: "/home/nextcloud/{{ item }}"
@@ -57,4 +57,4 @@
with_items:
- "{{ inventory_hostname }}.normal.crt"
- "{{ inventory_hostname }}.crt"
#- "{{ inventory_hostname }}.key"
- "{{ inventory_hostname }}.key"
+32 -31
View File
@@ -1,43 +1,44 @@
- name: Container Path data State directory
- name: Container directory paths
file:
path: "/home/{{ user.name }}/webroot"
path: "/home/{{ user.name }}/{{ subdir }}"
state: directory
owner: "100999"
group: "100999"
owner: "100033"
group: "100033"
with_items:
- "webroot"
- "web"
- "proxy/certs"
- "proxy/conf.d"
- "proxy/vhost.d"
loop_control:
loop_var: "subdir"
- name: Container Path certs State directory
file:
path: "/home/{{ user.name }}/nginx/certs"
state: directory
owner: "100999"
group: "100999"
- name: Container Path html State directory
file:
path: "/home/{{ user.name }}/nginx/html"
state: directory
owner: "100999"
group: "100999"
- name: Cointainer Path challenges directory
file:
path: "/home/{{ user.name }}/nginx/challenges"
- name: Create proxy uploadsize.conf File
template:
src: "proxy/uploadsize.conf"
dest: "/home/{{ user.name }}/proxy/conf.d/uploadsize.conf"
owner: "{{ user.name }}"
group: "{{ user.name }}"
state: directory
owner: "100999"
group: "100999"
- name: Create NGINX vhost file
- name: Create web nginx.conf File
template:
src: "nginx-vhost.j2"
dest: "/home/{{ user.name }}/nginx/vhost.d/{{ inventory_hostname }}"
owner: "100999"
group: "100999"
src: "web/nginx.conf"
dest: "/home/{{ user.name }}/web/nginx.conf"
owner: "{{ user.name }}"
group: "{{ user.name }}"
- name: Create Compose File
template:
src: "docker-compose.yml.j2"
dest: "/home/{{ user.name }}/docker-compose.yml"
owner: "100999"
group: "100999"
owner: "{{ user.name }}"
group: "{{ user.name }}"
- name: Create Compose env file
template:
src: "db.env.j2"
dest: "/home/{{ user.name }}/.db.env"
owner: "{{ user.name }}"
group: "{{ user.name }}"
force: false
+3
View File
@@ -0,0 +1,3 @@
POSTGRES_PASSWORD=
NEXTCLOUD_ADMIN_USER="admin"
NEXTCLOUD_ADMIN_PASSWORD=
+114 -38
View File
@@ -1,47 +1,123 @@
version: '3.6'
services:
db:
# Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server
image: postgres:alpine
hostname: db
restart: always
volumes:
- db:/var/lib/postgresql/data:Z
environment:
- POSTGRES_DB=nextcloud
env_file:
- .db.env
networks:
- podman
nextcloud:
redis:
image: redis:alpine
hostname: redis
restart: always
networks:
- podman
app:
image: nextcloud:stable-fpm
hostname: app
restart: always
ports:
- 9000:9000
environment:
VIRTUAL_PROTO: "fastcgi"
VIRTUAL_HOST: "{{ inventory_hostname | default('ansible_undefined_fact') }}"
VIRTUAL_ROOT: "/var/www/html/"
LETSENCRYPT_HOST: "{{ inventory_hostname | default('ansible_undefined_fact') }}"
POSTGRES_DB: "nextclouddb"
POSTGRES_USER: "nextcloud"
POSTGRES_HOST: "database"
NEXTCLOUD_TRUSTED_DOMAINS: "{{ inventory_hostname | default('ansible_undefined_fact') }}"
networks:
default:
aliases:
- "test-eqit.lan"
- "9000:9000"
volumes:
- ~/webroot:/var/www/html
- /home/{{ user.name }}/webroot:/var/www/html
environment:
- REDIS_HOST=redis
- POSTGRES_HOST=db:5432
- POSTGRES_DB=nextcloud
- POSTGRES_USER=postgres
- NEXTCLOUD_ADMIN_USER=admin
- NEXTCLOUD_TRUSTED_DOMAINS={{ inventory_hostname | default('ansible_undefined_variable')}}
env_file:
- .db.env
networks:
podman:
aliases:
- "nextcloud.local"
depends_on:
- db
- redis
- proxy
database:
image: postgres:latest
web:
image: nginx:alpine-slim
hostname: web
restart: always
networks:
default:
aliases:
"nextcloud-db.lan"
nginx-proxy:
restart: unless-stopped
ports:
- 8080:8080
- 4443:4443
image: nginxproxy/nginx-proxy:1.9-alpine
environment:
HTTP_PORT: 8080
HTTPS_PORT: 4443
volumes:
- /run/user/1000/podman/podman.sock:/tmp/docker.sock:ro
- /home/nextcloud/nginx/certs:/etc/nginx/certs
- /home/nextcloud/nginx/challenges:/usr/share/nginx/html
- /home/nextcloud/nginx/vhost.d:/etc/nginx/vhost.d
# https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html
- /home/{{ user.name }}/web/nginx.conf:/etc/nginx/nginx.conf:ro
# NOTE: The `volumes` included below should match those of the `app` container (unless you know what you're doing)
- /home/{{ user.name }}/webroot:/var/www/html:z,ro
environment:
- VIRTUAL_HOST={{ inventory_hostname | default('ansible_undefined_variable')}}
- LETSENCRYPT_HOST={{ inventory_hostname | default('ansible_undefined_variable')}}
- LETSENCRYPT_EMAIL="admin@libre.audio"
depends_on:
- app
networks:
- proxy-tier
- podman
cron:
image: nextcloud:fpm-alpine
hostname: cron
restart: always
volumes:
- /home/{{ user.name }}/webroot:/var/www/html:z
# NOTE: The `volumes` config of the `cron` and `app` containers must match
entrypoint: /cron.sh
networks:
- podman
depends_on:
- db
- redis
# Warning: Do not use :latest tags of nginx-proxy unless absolutely sure about the consequences.
proxy:
image: nginxproxy/nginx-proxy:1.7-alpine
hostname: proxy
restart: always
ports:
- 8080:80
- 4443:443
labels:
- "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
volumes:
- /home/{{ user.name }}/proxy/certs:/etc/nginx/certs:z,ro
- /home/{{ user.name }}/proxy/conf.d:/etc/nginx/conf.d:z
- /home/{{ user.name }}/proxy/vhost.d:/etc/nginx/vhost.d:z
- proxy_html:/usr/share/nginx/html:z
- /run/user/{{ getent_passwd[user.name][2] }}/podman/podman.sock:/tmp/docker.sock:ro
networks:
- proxy-tier
acme-companion:
image: nginxproxy/acme-companion:latest
volumes:
- proxy_html:/usr/share/nginx/html:z
- /home/{{ user.name }}/nginx/certs:/etc/nginx/certs:z
- /run/user/{{ getent_passwd[user.name][2] }}/podman/podman.sock:/var/run/docker.sock:ro
- acme:/etc/acme.sh
environment:
DEFAULT_EMAIL: "admin@libre.audio"
NGINX_PROXY_CONTAINER: "{{ user.name }}_proxy_1"
networks:
- proxy-tier
depends_on:
- proxy
volumes:
acme:
db:
proxy_html:
networks:
proxy-tier:
podman:
+2
View File
@@ -0,0 +1,2 @@
client_max_body_size 10G;
proxy_request_buffering off;
+202
View File
@@ -0,0 +1,202 @@
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
types {
text/javascript mjs;
}
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;
# Prevent nginx HTTP Server Detection
server_tokens off;
keepalive_timeout 65;
# Set the `immutable` cache control options only for assets with a cache busting `v` argument
map $arg_v $asset_immutable {
"" "";
default ", immutable";
}
#gzip on;
resolver 10.89.0.1 valid=2s;
upstream php-handler {
zone backends 64k;
server app:9000 ;
}
server {
listen 80;
# 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 512M;
client_body_timeout 300s;
fastcgi_buffers 64 4K;
# 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;
# 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;
# HTTP response headers borrowed from Nextcloud `.htaccess`
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "noindex, nofollow" 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/html;
# 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`, `/ocm-provider`, `/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 {
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 /remote.php/dav/; }
location = /.well-known/caldav { return 301 /remote.php/dav/; }
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 /index.php$request_uri;
}
# Rules borrowed from `.htaccess` to hide certain paths from clients
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; }
location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; }
# 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(_arm64)?\/proxy) /index.php$request_uri;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice
fastcgi_param front_controller_active true; # Enable pretty urls
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
fastcgi_max_temp_file_size 0;
}
# Serve static files
location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac)$ {
try_files $uri /index.php$request_uri;
add_header Cache-Control "public, max-age=15778463$asset_immutable";
add_header Referrer-Policy "no-referrer" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Permitted-Cross-Domain-Policies "none" always;
add_header X-Robots-Tag "noindex, nofollow" always;
add_header X-XSS-Protection "1; mode=block" always;
access_log off; # Optional: Don't log access to assets
location ~ \.wasm$ {
default_type application/wasm;
}
}
location ~ \.(otf|woff2?)$ {
try_files $uri /index.php$request_uri;
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;
}
}
}