Различия
Показаны различия между двумя версиями страницы.
Предыдущая версия справа и слева Предыдущая версия Следующая версия | Предыдущая версия | ||
application:nextcloud [2025/02/21 01:42] – mirocow | application:nextcloud [2025/03/05 22:22] (текущий) – mirocow | ||
---|---|---|---|
Строка 2: | Строка 2: | ||
====== Nextcloud ====== | ====== Nextcloud ====== | ||
+ | |||
+ | * / | ||
+ | * / | ||
+ | * / | ||
+ | * / | ||
+ | * / | ||
+ | |||
+ | ====== Установка ====== | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | ===== Установка Onlyoffice + Drawio + Drawio Export ===== | ||
nano docker_compose.yml | nano docker_compose.yml | ||
Строка 12: | Строка 25: | ||
nginx: | nginx: | ||
container_name: | container_name: | ||
- | image: nginx | + | image: nginx:latest |
restart: always | restart: always | ||
networks: | networks: | ||
Строка 26: | Строка 39: | ||
# - 192.168.1.6: | # - 192.168.1.6: | ||
volumes: | volumes: | ||
+ | - / | ||
- proxy:/ | - proxy:/ | ||
- | - data:/ | + | - nextcloud:/ |
# docker exec -u www-data nextcloud-app php occ config: | # docker exec -u www-data nextcloud-app php occ config: | ||
# docker exec -u www-data nextcloud-app php occ --no-warnings config: | # docker exec -u www-data nextcloud-app php occ --no-warnings config: | ||
# docker exec -u www-data nextcloud-app php occ --no-warnings config: | # docker exec -u www-data nextcloud-app php occ --no-warnings config: | ||
+ | # docker exec -u www-data nextcloud-app php occ --no-warnings config: | ||
+ | # docker exec -u www-data nextcloud-app php occ upgrade | ||
app: | app: | ||
- | image: nextcloud:latest | + | image: nextcloud:30.0-apache |
container_name: | container_name: | ||
networks: | networks: | ||
Строка 45: | Строка 62: | ||
volumes: | volumes: | ||
- / | - / | ||
- | - data:/ | + | - nextcloud:/ |
+ | #- nextcloud_custom_apps:/ | ||
+ | #- nextcloud_config:/ | ||
+ | #- nextcloud_data:/ | ||
+ | #- nextcloud_themes:/ | ||
environment: | environment: | ||
- TZ=Europe/ | - TZ=Europe/ | ||
Строка 52: | Строка 73: | ||
- SKIP_DOMAIN_VALIDATION=true | - SKIP_DOMAIN_VALIDATION=true | ||
restart: unless-stopped | restart: unless-stopped | ||
+ | |||
+ | deploy: | ||
+ | resources: | ||
+ | limits: | ||
+ | cpus: ' | ||
+ | memory: 7G | ||
+ | healthcheck: | ||
+ | test: [" | ||
+ | interval: 10s | ||
+ | timeout: 5s | ||
+ | retries: 3 | ||
+ | start_period: | ||
# http:// | # http:// | ||
Строка 102: | Строка 135: | ||
cron: | cron: | ||
- | image: nextcloud:latest | + | image: |
restart: unless-stopped | restart: unless-stopped | ||
+ | network_mode: | ||
+ | depends_on: | ||
+ | - app | ||
volumes: | volumes: | ||
- | | + | |
- | - data:/var/www/html:z | + | - / |
+ | - crontabs:/ | ||
environment: | environment: | ||
- | | + | |
- | | + | |
- | | + | - NEXTCLOUD_CRON_MINUTE_INTERVAL=5 |
- | | + | |
- | - redis | + | |
- | networks: | + | |
- | nextcloud_network: | + | |
db: | db: | ||
Строка 131: | Строка 164: | ||
- MYSQL_DATABASE=nextcloud | - MYSQL_DATABASE=nextcloud | ||
- MYSQL_USER=nextcloud | - MYSQL_USER=nextcloud | ||
+ | ports: | ||
+ | - 13306:3306 | ||
restart: unless-stopped | restart: unless-stopped | ||
+ | deploy: | ||
+ | resources: | ||
+ | limits: | ||
+ | cpus: ' | ||
+ | memory: 4G | ||
redis: | redis: | ||
image: redis: | image: redis: | ||
restart: unless-stopped | restart: unless-stopped | ||
+ | deploy: | ||
+ | resources: | ||
+ | limits: | ||
+ | cpus: ' | ||
+ | memory: 2G | ||
+ | networks: | ||
+ | nextcloud_network: | ||
+ | |||
+ | es01: | ||
+ | image: elasticsearch: | ||
+ | container_name: | ||
+ | restart: always | ||
+ | environment: | ||
+ | node.name: elasticsearch | ||
+ | bootstrap.memory_lock: | ||
+ | ES_JAVA_OPTS: | ||
+ | xpack.security.enabled: | ||
+ | # Bootstrap password. | ||
+ | # Used to initialize the keystore during the initial startup of | ||
+ | # Elasticsearch. Ignored on subsequent runs. | ||
+ | # ELASTIC_PASSWORD: | ||
+ | # Use single node discovery in order to disable production mode and avoid bootstrap checks. | ||
+ | # see: https:// | ||
+ | discovery.type: | ||
+ | ulimits: | ||
+ | memlock: | ||
+ | soft: -1 | ||
+ | hard: -1 | ||
+ | volumes: | ||
+ | - data01:/ | ||
+ | expose: | ||
+ | - 9200 | ||
+ | - 9300 | ||
networks: | networks: | ||
nextcloud_network: | nextcloud_network: | ||
Строка 141: | Строка 214: | ||
volumes: | volumes: | ||
proxy: | proxy: | ||
- | | + | |
+ | crontabs: | ||
db: | db: | ||
document_data: | document_data: | ||
document_log: | document_log: | ||
+ | data01: | ||
| | ||
Строка 162: | Строка 237: | ||
</ | </ | ||
- | <code bash> | + | |
- | $ docker compose up -d | + | ===== Настройка прокси-сервера ===== |
- | $ docker exec -u www-data nextcloud-app php occ config: | + | |
- | $ 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: | + | |
- | $ docker exec -u www-data nextcloud-app php occ --no-warnings config: | + | |
- | </ | + | |
nano / | nano / | ||
Строка 188: | Строка 258: | ||
log_format | log_format | ||
- | | + | |
- | '" | + | '" |
access_log | access_log | ||
Строка 219: | Строка 289: | ||
server_tokens off; | server_tokens off; | ||
- | # Add headers | + | # HSTS settings |
- | add_header Strict-Transport-Security " | + | # WARNING: Only add the preload option once you read about |
- | add_header X-Content-Type-Options nosniff; | + | # the consequences in https:// |
- | add_header X-XSS-Protection "1; mode=block"; | + | # will add the domain |
- | add_header X-Robots-Tag none; | + | |
- | add_header X-Download-Options noopen; | + | # could take several months. |
- | add_header X-Permitted-Cross-Domain-Policies none; | + | #add_header Strict-Transport-Security " |
- | | + | # set max upload size and increase upload timeout: |
- | client_max_body_size 10G; # 0=unlimited - set max upload size | + | client_max_body_size 512M; |
+ | client_body_timeout 300s; | ||
fastcgi_buffers 64 4K; | fastcgi_buffers 64 4K; | ||
- | gzip off; | + | |
+ | 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/ | ||
+ | |||
+ | # Pagespeed is not supported by Nextcloud, so if your server is built | ||
+ | # with the `ngx_pagespeed` module, uncomment this line to disable it. | ||
+ | # | ||
+ | |||
+ | # The settings allows you to optimize the HTTP2 bandwidth. | ||
+ | # See https:// | ||
+ | # for tuning hints | ||
+ | client_body_buffer_size 512k; | ||
+ | |||
+ | # HTTP response headers borrowed from Nextcloud `.htaccess` | ||
+ | add_header Referrer-Policy | ||
+ | add_header X-Content-Type-Options | ||
+ | add_header X-Frame-Options | ||
+ | add_header X-Permitted-Cross-Domain-Policies | ||
+ | add_header X-Robots-Tag | ||
+ | add_header X-XSS-Protection | ||
+ | |||
+ | # Remove X-Powered-By, | ||
+ | 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/ | ||
+ | application/ | ||
+ | } | ||
+ | |||
+ | # Specify how to handle directories -- specifying `/ | ||
+ | # 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' | ||
+ | # 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`, `/ | ||
+ | # `try_files $uri $uri/ / | ||
+ | # always provides the desired behaviour. | ||
+ | index index.php index.html / | ||
+ | |||
+ | # Rule borrowed from `.htaccess` to handle Microsoft DAV clients | ||
+ | #location = / { | ||
+ | # if ( $http_user_agent ~ ^DavClnt ) { | ||
+ | # return 302 / | ||
+ | # } | ||
+ | #} | ||
+ | |||
+ | location = /robots.txt { | ||
+ | allow all; | ||
+ | log_not_found off; | ||
+ | access_log off; | ||
+ | } | ||
+ | |||
+ | # Make a regex exception for `/ | ||
+ | # access it despite the existence of the regex rule | ||
+ | # `location ~ / | ||
+ | # for `/ | ||
+ | location ^~ / | ||
+ | # The rules in this block are an adaptation of the rules | ||
+ | # in `.htaccess` that concern `/ | ||
+ | |||
+ | location = / | ||
+ | location = / | ||
+ | |||
+ | location / | ||
+ | location / | ||
+ | |||
+ | # Let Nextcloud' | ||
+ | # requests by passing them to the front-end controller. | ||
+ | return 301 / | ||
+ | } | ||
+ | |||
+ | # Rules borrowed from `.htaccess` to hide certain paths from clients | ||
+ | location ~ ^/ | ||
+ | location ~ ^/ | ||
index index.php; | index index.php; | ||
Строка 245: | Строка 400: | ||
proxy_set_header X-Real-IP $remote_addr; | proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | 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-Host $the_host; |
proxy_set_header X-Forwarded-Proto $the_scheme; | proxy_set_header X-Forwarded-Proto $the_scheme; | ||
+ | # Correct handling of fallbacks for HTTP headers | ||
+ | proxy_hide_header X-Permitted-Cross-Domain-Policies; | ||
+ | proxy_hide_header | ||
+ | proxy_hide_header | ||
+ | proxy_hide_header | ||
+ | proxy_hide_header | ||
} | } | ||
Строка 262: | Строка 423: | ||
proxy_set_header X-Forwarded-Host $the_host/ | proxy_set_header X-Forwarded-Host $the_host/ | ||
proxy_set_header X-Forwarded-Proto $the_scheme; | proxy_set_header X-Forwarded-Proto $the_scheme; | ||
+ | # Correct handling of fallbacks for HTTP headers | ||
+ | proxy_hide_header X-Permitted-Cross-Domain-Policies; | ||
+ | proxy_hide_header | ||
+ | proxy_hide_header | ||
+ | proxy_hide_header | ||
+ | proxy_hide_header | ||
} | } | ||
Строка 270: | Строка 437: | ||
client_max_body_size 100m; | client_max_body_size 100m; | ||
proxy_http_version 1.1; | proxy_http_version 1.1; | ||
- | proxy_set_header Upgrade $http_upgrade; | + | |
- | proxy_set_header Connection " | + | |
- | 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/ | + | |
- | proxy_set_header X-Forwarded-Proto $the_scheme; | + | |
+ | } | ||
+ | |||
+ | location /service/0 { | ||
+ | rewrite / | ||
+ | proxy_pass http:// | ||
+ | proxy_redirect | ||
+ | client_max_body_size 100m; | ||
+ | proxy_http_version 1.1; | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | # | ||
+ | #proxy_set_header X-Forwarded-Proto $the_scheme; | ||
} | } | ||
Строка 282: | Строка 464: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | ===== Продолжение настройки ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec nextcloud-app rm / | ||
+ | </ | ||
+ | |||
+ | ===== Установка контейнера и настройка приложения ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker compose up -d | ||
+ | $ docker exec -u www-data nextcloud-app php occ config: | ||
+ | $ docker exec -u www-data nextcloud-app php occ app:install onlyoffice | ||
+ | $ docker exec -u www-data nextcloud-app php occ --no-warnings config: | ||
+ | $ docker exec -u www-data nextcloud-app php occ --no-warnings config: | ||
+ | $ docker exec -u www-data nextcloud-app php occ --no-warnings config: | ||
+ | </ | ||
+ | |||
+ | * trusted_domains 1 - Индекс в массиве trusted_domains | ||
+ | |||
+ | |||
+ | ===== Fulltextsearch + Elasticsearch ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec nextcloud-app curl -XGET ' | ||
+ | $ docker exec -u www-data nextcloud-app php occ fulltextsearch: | ||
+ | $ docker exec -u www-data nextcloud-app php occ full:index | ||
+ | </ | ||
+ | |||
+ | ===== OCC ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec -u www-data nextcloud-app php occ config: | ||
+ | $ docker exec -u www-data nextcloud-app php occ config: | ||
+ | $ docker exec -u www-data nextcloud-app php occ config: | ||
+ | $ docker exec -u www-data nextcloud-app php occ upgrade | ||
+ | $ docker exec nextcloud-app php -r " | ||
+ | $ docker exec nextcloud-app php composer-setup.php | ||
+ | $ docker exec nextcloud-app mv / | ||
+ | $ docker exec nextcloud-app chmod +x / | ||
+ | </ | ||
+ | |||
+ | ===== Maintenance ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec -u www-data nextcloud-app php occ maintenance: | ||
+ | $ docker exec -u www-data nextcloud-app php occ maintenance: | ||
+ | </ | ||
+ | |||
+ | ===== Logfile ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec -u www-data nextcloud-app bash -c 'cd / | ||
+ | </ | ||
+ | |||
+ | ===== Composer ===== | ||
+ | |||
+ | ==== Install ==== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec nextcloud-app php -r " | ||
+ | docker exec nextcloud-app php composer-setup.php && \ | ||
+ | docker exec nextcloud-app mv composer.phar / | ||
+ | docker exec nextcloud-app composer -v | ||
+ | </ | ||
+ | |||
+ | ==== Использование ==== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec -u www-data nextcloud-app bash -c 'cd / | ||
+ | $ docker exec -u www-data nextcloud-app bash -c 'cd / | ||
+ | </ | ||
+ | |||
+ | ===== User Data ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec -u www-data nextcloud-app bash -c 'cd / | ||
+ | </ | ||
+ | |||
+ | ===== Custom Application ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec nextcloud-app chown www-data: | ||
+ | $ docker exec -u www-data nextcloud-app bash -c 'cd / | ||
+ | </ | ||
+ | |||
+ | ===== Debug ===== | ||
+ | |||
+ | <code bash> | ||
+ | $ docker exec nextcloud-app pecl install xdebug && \ | ||
+ | docker exec nextcloud-app docker-php-ext-enable xdebug && \ | ||
+ | docker exec nextcloud-app rm -rf /tmp/pear && \ | ||
+ | docker exec nextcloud-app bash -c 'echo " | ||
+ | xdebug.start_with_request=yes | ||
+ | xdebug.client_host=host.docker.internal | ||
+ | ;# 9003 is now the default (set this for old PhpStorm settings). | ||
+ | xdebug.client_port=9000" | ||
+ | php -i|grep xdebug | ||
+ | </ | ||
+ | |||
+ |