前言
暑假放假回家,正好手上有一闲置国产派,打算当个nas用。收上也还有几块闲置硬盘,所以这里就装一下,并记录一下。
一、Docker的安装
这里详见之前文章,这里略过。
二、Nextcloud 的安装
关于用户权限
毕竟这个香橙派没太多想干的事情,因此直接全程root了。
关于系统信息:
$ uname
$ lsb_release
Nginx 环境配置
mkdir -p /data/nginx/
mkdir -p /data/nginx/conf.d/
mkdir -p /data/nginx/ssl/
vim /data/nginx/nginx.conf
添加以下内容:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
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;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
配置反向代理
vim /data/nginx/conf.d/default.conf
添加:
upstream nextcloud{
server 192.168.0.104:8888; #此处填写nextcloud云盘的 ip:port 如果是本机填写 localhost
}
server {
listen 443 ssl http2; #nginx监听443端口
#listen [::]:443 ssl http2;
server_name 192.168.0.104; #此处填写nextcloud云盘的ip 如果是本机填写 localhost
#ssl on;
#listen 443 ssl;
ssl_certificate /etc/nginx/ssl/nginx.crt;#填下面生成的证书路径
ssl_certificate_key /etc/nginx/ssl/nginx.key;#填下面生成的证书路径
client_max_body_size 100G;
proxy_buffer_size 2m;
proxy_buffers 8 1m;
proxy_busy_buffers_size 2m;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
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;
}
location / {
proxy_redirect off;
proxy_pass http://nextcloud;
proxy_set_header Host $http_host;
}
location = /.htaccess {
return 404;
}
}
注意这里有两个地方需要修改成你的ip地址
生成SSL证书
openssl genrsa -out /data/nginx/ssl/nginx.key 2048
openssl req -new -key /data/nginx/ssl/nginx.key -out /data/nginx/ssl/nginx.csr
openssl x509 -req -days 36500 -in /data/nginx/ssl/nginx.csr -signkey /data/nginx/ssl/nginx.key -out /data/nginx/ssl/nginx.crt
配置 Dockerfile
vim Dockerfile
添加以下内容
FROM nextcloud:latest
LABEL maintainer="engr-z"
RUN apt update && apt upgrade -y
RUN apt install ffmpeg smbclient libsmbclient-dev -y
RUN pecl install smbclient
RUN docker-php-ext-enable smbclient
配置 docker-compose.yml
vim docker-compose.yml
version: "3.5"
services:
nginx:
container_name: nginx
hostname: nginx
image: nginx
ports:
- 8081:8081
- 443:443
restart: always
volumes:
- /data/nextcloud:/usr/share/nginx/html
- /data/nginx/nginx.conf:/etc/nginx/nginx.conf
- /data/nginx/conf.d/:/etc/nginx/conf.d
- /data/nginx/ssl:/etc/nginx/ssl
- /data/nginx/log:/var/log/nginx
nextcloud:
build:
context: .
dockerfile: ./Dockerfile
ports:
- "8888:80"
restart: always
volumes:
- /data/nextcloud/themes:/var/www/html/themes/
- /data/nextcloud/apps:/var/www/html/custom_apps
- /data/nextcloud/config:/var/www/html/config
- /data/nextcloud/data:/var/www/html/data
environment:
- POSTGRES_HOST=nc-postgres # HERE
- POSTGRES_DB=nextcloud_db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=Pg123
depends_on:
- db
redis:
image: redis
container_name: nextcloud_redis
hostname: redis
restart: always
ports:
- "6379:6379"
aria2:
image: wahyd4/aria2-ui:nextcloud
container_name: nextcloud_aria2
hostname: aria2
ports:
- "8000:80"
- "6800:6800"
volumes:
- /data/aria2/app/conf:/root/conf
- /data/aria2/data:/data
environment:
- DOMAIN=:80
# - SSL=true
# - RPC_SECRET=Hello
# - ARIA2_USER=111111
# - ARIA2_PWD=111111
# - ENABLE_AUTH=true
restart: always
db:
image: postgres
restart: always
container_name: nextcloud_postgres
hostname: 'nc-postgres' # AND HERE
volumes:
- /data/postgresql:/var/lib/postgresql/data
environment:
- POSTGRES_DB=nextcloud_db
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=Pg123
安装
docker-compose build
docker-compose up -d
等待一段时间,即可启动。
之后可以通过如下命令查看Nextcloud的运行状态:
docker ps
最后,访问 http://你的ip:8888/ 进行一些初始化配置,就完成安装了。
硬盘挂载
毕竟香橙派只有8G的emmc,而且速度非常慢。因此这里需要插入外置存储。
这里我通过硬盘盒放入一块2.5寸的硬盘,然后插入香橙派的USB接口中。之后,通过:
fdisk -l
可以找到我们移动硬盘的信息。之后,通过mount挂载:
mount /dev/sdb2 /mnt/wd2t1
Nextcloud默认是没有开启外部存储功能的,需在手动启用插件:
References
树莓派4B基于docker安装nextcloud,并且配置https,内网穿透,性能优化,死机重启,配置samba以及缩略图
树莓派搭建next_cloud,挂载外部存储以及内网穿透记录
https://blog.csdn.net/qq_34177812/article/details/107077674
评论 (0)