Docker部署NextCloud
啟動mariadb
[root@test4 ~]# docker run -d \
--name mysql \
-e MYSQL_ROOT_PASSWORD=Flz_3qc123 \
-p 13306:3306 \
-v /docker/volumns/mysql/data:/var/lib/mysql \
--restart unless-stopped \
mariadb:10.4.7-bionic
啟動nextcloud-fpm
[root@test4 ~]# docker run -d \
--name nextcloud \
-v /mnt/hdd2/nextcloud/html:/var/www/html \
-v /mnt/hdd2/nextcloud/custom_apps:/var/www/html/custom_apps \
-v /mnt/hdd2/nextcloud/config:/var/www/html/config \
-v /mnt/hdd2/nextcloud/data:/var/www/html/data \
--link mysql:mysql \
--restart unless-stopped \
nextcloud:16.0.4-fpm
nginx配置
1.將ssl證書放入宿主機/opop/certs目錄下
2.將下方配置文件放入宿主機/opop/conf目錄下,命名任意必須以.conf結尾
mkdir -p /opop/{cert,conf}
cd /opop/cert
[root@test4 cert]# openssl genrsa -out cert.key 2048
[root@test4 cert]# openssl req -new -x509 -key cert.key -out cert.pem -days 9999 #9999為有效期(天)
Country Name (2 letter code) [XX]: 所在國家,示例:CN
State or Province Name (full name) []:所在省,示例:Guangdong
Locality Name (eg, city) [Default City]: 所在市,示例Foshan
Organization Name (eg, company) [Default Company Ltd]: 公司名,示例:tengxun
Organizational Unit Name (eg, section) []: 所在部門,示例:jishubu
Common Name (eg, your name or your server's hostname) []: 這個自己翻譯,示例:tengxun.com
Email Address []: 郵箱,示例:admin@admin.com
[root@test2 cert]# cd ../conf
[root@test4 conf]# vim nextcloud.conf
upstream php-handler {
server nextcloud:9000;
}
server {
listen 80;
listen [::]:80;
server_name 172.16.186.155;
# enforce https
return 301 https://$server_name:443$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name 172.16.186.155;
# Use Mozilla's guidelines for SSL/TLS settings
# https://mozilla.github.io/server-side-tls/ssl-config-generator/
# NOTE: some settings below might be redundant
ssl_certificate /etc/nginx/ssl_certs/cert.pem;
ssl_certificate_key /etc/nginx/ssl_certs/cert.key;
# 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;
add_header Referrer-Policy no-referrer;
add_header Strict-Transport-Security 15552000;
# add_header X-Frame-Options SAMEORIGIN;
# 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;
# 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;
# The following rule is only needed for the Social app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/webfinger /public.php?service=webfinger last;
location = /.well-known/carddav {
return 301 $scheme://$host:$server_port/remote.php/dav;
}
location = /.well-known/caldav {
return 301 $scheme://$host:$server_port/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$request_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\/.+|oc[ms]-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;
# Enable pretty urls
fastcgi_param front_controller_active true;
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {
try_files $uri/ =404;
index index.php;
}
# Adding the cache control header for js, css and map files
# Make sure it is BELOW the PHP block
location ~ \.(?:css|js|woff2?|svg|gif|map)$ {
try_files $uri /index.php$request_uri;
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;
add_header Referrer-Policy no-referrer;
# Optional: Don't log access to assets
access_log off;
}
location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ {
try_files $uri /index.php$request_uri;
# Optional: Don't log access to other assets
access_log off;
}
}
啟動nginx
[root@test4 ~]# docker run -d \
--name nginx \
-p 80:80 -p 443:443 \
-v /mnt/hdd2/nextcloud/html:/var/www/html \
-v /opop/conf:/etc/nginx/conf.d \
-v /opop/cert:/etc/nginx/ssl_certs \
--link mysql:mysql \
--link nextcloud:nextcloud \
--restart unless-stopped \
nginx
==================== 可選項 ============================
進入容器進行設置(設置前可瀏覽器訪問,但不能進行視頻通話)
docker exec -it <nextcloud_containerID> /bin/bash
apt-get update
cp /etc/apt/sources.list{,.bak}
#將官網源換位國內源(按需),這里我使用阿里的源
網易的源
cat > /etc/apt/sources.list << EOF
deb http://mirrors.163.com/debian/ buster main contrib non-free
deb http://mirrors.163.com/debian/ buster-updates main contrib non-free
deb http://mirrors.163.com/debian/ buster-backports main contrib non-free
deb http://mirrors.163.com/debian-security buster/updates main contrib non-free
EOF
阿里源
cat > /etc/apt/sources.list << EOF
deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib
deb http://mirrors.aliyun.com/debian-security stretch/updates main
deb-src http://mirrors.aliyun.com/debian-security stretch/updates main
deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib
deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
EOF
官方的源
cat > /etc/apt/sources.list << EOF
deb http://deb.debian.org/debian buster main contrib non-free
deb-src http://deb.debian.org/debian buster main contrib non-free
deb http://security.debian.org/debian-security buster/updates main contrib
deb-src http://security.debian.org/debian-security buster/updates main contrib
EOF
apt-get update
安裝部分命令示例:apt-get install vim wget -y
==================== 可選項 ============================
瀏覽器訪問
https://172.16.186.155/index.php
“高級”----”繼續訪問不安全”
管理員/密碼都為自定義,數據庫自定義(會自動創建),數據庫主機中寫mysql,即容器名稱
安裝Talk插件(視頻使用)
點擊最右上角的"小軸承"----點擊應用,暫且不要退出
從nextcloud store官網下載 Talk組件:https://apps.nextcloud.com/apps/spreed (Unstable為不穩定版本)
這里用的是6.0.5版本
[root@test4 ~]# https://github.com/nextcloud/spreed/releases/download/v6.0.5/spreed-6.0.5.tar.gz (這里也有公私玥,最高支持到6.0.5)
[root@test4 ~]# tar -zxvf spreed-6.0.5.tar.gz
獲取nextcloud容器ID
[root@test4 ~]# docker ps -a
將解壓出來的spreed目錄放到容器的指定位置
[root@test4 ~]# docker cp spreed 54ed3b335c6a:/var/www/html/apps/spreed
再次來到web頁面刷新下頁面,下圖為未刷新前
下圖為刷新頁面后的,點擊”啟用未經測試的應用”即可,啟用時需要輸入一次密碼
然后點Talk字體最右側的”啟用”
啟用后在頁面的左上角會多一個放大鏡的圖標,即”通話”
添加分組
點擊下圖中最右側的用戶名(即本文檔中的A字樣),點擊"用戶"
點擊”添加分組”
輸入好組名(這里組名為"opop公司")后點擊右側小箭頭
添加用戶
點擊”新建用戶”,用戶名必須為英文,設置好以后點最右側的對號添加用戶完成
填寫好用戶的信息后點擊用戶行最後面的對號即創建成功
這里已同樣的方式再添加一個lisi(李四)用戶並將該用戶設置為opop公司的管理員,如下圖所示(刷新頁面即在下圖左下角的opop分組中看到是2個用戶)
服務端(即安裝nextcloud服務的機器)創建視頻會話
下圖中點擊右上角的放大鏡(鼠標放上去會有中文顯示)
點擊"新的會話"
點擊"opop公司"
點擊右側的"開始通話"
點擊"允許" 即可調用麥和攝像頭(這里請忽略IP地址)
截止到此處,您的攝像頭即已為打開模式
客戶端登錄
其他用戶在遠端訪問:https://172.16.186.155進行登錄,而后進行視頻的用戶,這里我用手機並用zhangsan用戶登錄(記得地址中是https而非http)
點擊上圖中最頂端放大鏡(偏左)左面的三個點---通話
點擊上圖中圈住的部分后即可以看到"opop公司",點擊"opop公司"進去----點擊"加入通話"
下圖中的IP請忽略,操作步驟沒錯
就目前而言雖然聯通了,但是偶爾會有一些雜音,不確定是什么問題,如手機端將頁面轉入后台后,那么對方看到的將是卡住的狀態,請注意!!!
Github上nextcloud:https://github.com/nextcloud/spreed
Nextcloud-talk API文檔:https://nextcloud-talk.readthedocs.io/en/latest/conversation/
歡迎加入QQ群一起討論Linux、開源等技術