Nextcloud

Установка

nano docker_compose.yml

version: '3' services: # http://192.168.1.6 nginx: container_name: nextcloud-proxy image: nginx restart: always networks: localnetwork: ipv4_address: "192.168.1.6" nextcloud_network: depends_on: - app - drawio - onlyoffice ports: - 192.168.1.6:80:80 # - 192.168.1.6:443:443 volumes: - proxy:/etc/nginx - data:/var/www/html # docker exec -u www-data nextcloud-app php occ config:system:set trusted_domains 4 --value=178.140.10.58 # docker exec -u www-data nextcloud-app php occ --no-warnings config:system:set onlyoffice DocumentServerUrl --value="/ds-vpath/" # docker exec -u www-data nextcloud-app php occ --no-warnings config:system:set onlyoffice DocumentServerInternalUrl --value="http://onlyoffice-document-server/" app: image: nextcloud:latest container_name: nextcloud-app networks: nextcloud_network: expose: - '80' - '9000' depends_on: - db - redis volumes: - /etc/localtime:/etc/localtime:ro - data:/var/www/html:z environment: - TZ=Europe/Moscow - MYSQL_HOST=db - REDIS_HOST=redis - SKIP_DOMAIN_VALIDATION=true restart: unless-stopped # http://nextcloud-drawio drawio: image: jgraph/drawio:dev container_name: nextcloud-drawio networks: nextcloud_network: expose: - '8080' depends_on: - image-export environment: - DRAWIO_SELF_CONTAINED=1 - EXPORT_URL=http://image-export:8000/ # - PLANTUML_URL=http://plantuml-server:8080/ # - DRAWIO_BASE_URL=${DRAWIO_BASE_URL} restart: unless-stopped # http://image-export:8000/ image-export: image: jgraph/export-server container_name: nextcloud-drawio-export expose: - "8000" networks: nextcloud_network: # environment: # - DRAWIO_SERVER_URL=${DRAWIO_BASE_URL} #volumes: #- ./fonts:/usr/share/fonts/drawio restart: unless-stopped # ONLYOFFICE Docs address: /ds-vpath/ # ONLYOFFICE Docs address for internal requests from the server: /nextcloud-onlyoffice/ onlyoffice: container_name: nextcloud-onlyoffice image: onlyoffice/documentserver:latest environment: - JWT_SECRET=secret networks: nextcloud_network: restart: unless-stopped expose: - '80' # - '443' volumes: - document_data:/var/www/onlyoffice/Data - document_log:/var/log/onlyoffice cron: image: nextcloud:latest restart: unless-stopped volumes: - /etc/localtime:/etc/localtime:ro - data:/var/www/html:z environment: - TZ=Europe/Moscow entrypoint: /cron.sh depends_on: - db - redis networks: nextcloud_network: db: image: mariadb:11.4.5 container_name: nextcloud-mariadb command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW networks: nextcloud_network: volumes: - /etc/localtime:/etc/localtime:ro - db:/var/lib/mysql:rw environment: - TZ=Europe/Moscow - MYSQL_ROOT_PASSWORD=toor - MYSQL_PASSWORD=mysql - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud restart: unless-stopped redis: image: redis:alpine restart: unless-stopped networks: nextcloud_network: volumes: proxy: data: db: document_data: document_log: networks: nextcloud_network: localnetwork: name: localnetwork driver: ipvlan driver_opts: parent: eno1 ipvlan_mode: l3 ipam: config: - subnet: "192.168.1.0/24" ip_range: "192.168.1.1/24" gateway: "192.168.1.1"

Установка контейнера и настройка приложения

$ docker compose up -d $ docker exec -u www-data nextcloud-app php occ config:system:set trusted_domains 4 --value=178.140.10.58 $ docker exec -u www-data -ti nextcloud-app php occ app:install onlyoffice $ docker exec -u www-data nextcloud-app php occ --no-warnings config:system:set onlyoffice DocumentServerUrl --value="/ds-vpath/" $ docker exec -u www-data nextcloud-app php occ --no-warnings config:system:set onlyoffice DocumentServerInternalUrl --value="http://onlyoffice-document-server/"

Настройка прокси-сервера

nano /etc/nginx/nginx.conf

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; map $http_host $this_host { "" $host; default $http_host; } map $http_x_forwarded_proto $the_scheme { default $http_x_forwarded_proto; "" $scheme; } map $http_x_forwarded_host $the_host { default $http_x_forwarded_host; "" $this_host; } server { listen 80; # The below allows for being behind a reverse proxy and allowing the Nextcloud app to connect server_tokens off; # 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; location / { proxy_pass http://nextcloud-app; proxy_redirect off; client_max_body_size 100m; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; 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; proxy_set_header X-Forwarded-Proto $the_scheme; } location ~* ^/ds-vpath/ { rewrite /ds-vpath/(.*) /$1 break; proxy_pass http://nextcloud-onlyoffice; proxy_redirect off; client_max_body_size 100m; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; 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; proxy_set_header X-Forwarded-Proto $the_scheme; } location ~* ^/drawio/ { rewrite /drawio/(.*) /$1 break; proxy_pass http://nextcloud-drawio:8080; proxy_redirect off; client_max_body_size 100m; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; 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; proxy_set_header X-Forwarded-Proto $the_scheme; } } }