为什么搭建属于自己的云盘?
1.最近想下载点资料下来发现还是每次下载某某网盘各种限制下载速度,各种广告看见就烦?
2.网盘里面收藏很多东西,最近发现不够觉得安全吗?可能我这人缺乏安全感吧!
3.发现自己之前收藏的电影看不了,这酸爽你懂的,迫于无奈,自己动手搭建个。
那么问题来了搭建自己的私有云有什么好处呢?首先没有什么容量、下载速度的限制,而且本地访问速度和同步速度很快。然后可以和本地的网页端,服务器端,pc端,和iPhone手机和安卓端都使用配合使用来实现多个设备文件共享挂载云盘中的文件来实现电影、看照片、可以私藏自己喜欢听的歌和文档word,pdf,等需求。最后可以防止泄密和和谐,最好放在自己的服务器上做好防火墙策略。
Nextcloud是由ownCloud发明者发起的下一代企业级文件同步及共享服务.
搭建Nextcloud服务, 重新夺回数据的控制权, 不受第三方限制.
使用Docker快速部署, 数据存储在容器之外, 随时可备份, 安全无风险.
Nextcloud核心功能如下:
- 文件访问及共享
- 安全访问控制
- 移动及桌面客户端
- 连接外部存储
- 日历及通讯录
- 安全语音及视频电话
- 在线办公协作
环境准备:
1.安装最新版本docker和docker-compose
2.挂在一块单独的数据盘挂在到 /data目录下
3.准备好一个备案过的域名和域名的https的证书
看下目录结构吧
下面请看使用docker完成Nextcloud云盘
1.拉取最新
docker pull docker.io/indiehosters/nextcloud
docker pull docker.io/nginx:alpine
2.把网站证书放在ssl目录下
nextcloud.key
nextcloud.crt
3.修改Nginx.conf配置文件
server {
listen 80 default;
server_name test.com;
location / {
return 301 https://servername" role="presentation">servernamerequest_uri;
}
}
server {
listen 443 ssl;
server_name test.com;
ssl_certificate /etc/nginx/ssl/1_www.test.com_bundle.crt;
ssl_certificate_key /etc/nginx/ssl/2_www.test.com.key;
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/[^\/]+/)" role="presentation">1/index.html;
try_files uri" role="presentation">uriuri/ =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 nextcloud:9000; fastcgi_intercept_errors on; } location ~* .(?:css|js)" role="presentation">|/) {
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 nextcloud:9000;
fastcgi_intercept_errors on;
}
location ~* .(?:css|js){
add_header Cache-Control “public, max-age=7200”;
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;
access_log off;
}
location ~* .(?:jpg|jpeg|gif|bmp|ico|png|swf)$ {
access_log off;
}
}
4.在data目录下创建目录 mkdir -p /data/{apps,config,data}
5.docker-compose的书写格式如下 docker-compose.yml
nginx:
image: nginx:alpine
ports:
- “80:80”
- “443:443”
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
- ./ssl:/etc/nginx/ssl
volumes_from:
- nextcloud
links:
- nextcloud
restart: always
nextcloud:
image: indiehosters/nextcloud
volumes:
- ./data/apps:/var/www/html/apps
- ./data/config:/var/www/html/config
- ./data/data:/var/www/html/data
restart: always
cron:
image: indiehosters/nextcloud
volumes_from:
- nextcloud
user: www-data
entrypoint: |
bash -c ‘bash -s < trap “break;exit” SIGHUP SIGINT SIGTERM
while /bin/true; do
/usr/local/bin/php /var/www/html/cron.php
sleep 900
done
EOF’
6.最近一步骤 docker-compose up -d 既可以完成部署,打开网站,配置数据库既可以完成
7.PC端,手机端,iPhone端,安卓端,MAC端,只要安装了统统都能同步,https://nextcloud.com/install/#install-clients
手机应用商店里搜下Nextcloud 即可下载,有不会请留言。