一个开源的网盘服务程序Droppy
安装步骤 演示使用的系统环境为Debian 8 Jessie x64。
Droppy基于Node.js,所以首先需要安装Node.js环境
|
|
安装Droppy
|
|
安装完成后使用droppy -h
可以查看运行命令。
如果需要让Droppy监听小于1024的端口
|
|
然后修改配置文件
重新运行droppy即可。
vi /root/.droppy/config/config.json
重新运行droppy即可。
参考
https://github.com/silverwind/droppy
---------
打造私人云存储: Droppy
Droppy是一个开源的网盘服务程序,只需通过浏览器就能够随时随地进行上传下载、预览编辑、外链分享等文件管理操作,功能强大,且十分轻量,非常适合作为个人的网络存储管理界面。
Droppy基于Node.js,所以首先需要安装Node.js环境
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential
安装Droppy:
sudo npm install -g droppy
添加一个无登录权限的用户和用户组用来运行Droppy:
groupadd -r droppy
useradd -r -s /bin/false -d /srv/droppy -g droppy droppy
建立所需目录,本例中文件存放目录为/srv/droppy/files,配置文件存放在/srv/droppy/config,可根据实际需求选择。
mkdir -p /srv/droppy/config /srv/droppy/files
chown -R droppy:droppy /srv/droppy
chmod 755 /srv/droppy
建立systemd服务脚本
vi /etc/systemd/system/droppy.service
编辑脚本内容:
[Unit]
Description=droppy
After=network.target
[Service]
ExecStart=/usr/bin/env droppy start -c /srv/droppy/config -f /srv/droppy/files
WorkingDirectory=/srv/droppy
Environment="NODE_ENV=production"
Restart=always
User=droppy
Group=droppy
SyslogIdentifier=droppy
[Install]
WantedBy=multi-user.target
Enable the service
使服务生效
systemctl daemon-reload
systemctl enable droppy
如果需要让Droppy监听小于1024的端口(比如常用的80端口)[非必需]
sudo apt-get install libcap2-bin
sudo setcap cap_net_bind_service=+ep `readlink -f \`which node\``
初始化配置文件并运行Droppy:
su droppy -c 'droppy --home /srv/droppy config'
systemctl start droppy
Droppy默认监听8989端口,服务运行后打开浏览器输入'你的服务器ip地址:8989'就可以看到Droppy的登录界面了,初始用户名为droppy,密码droppy。
如需改变端口,可在/srv/droppy/config/config.json中设置。
关于用户管理
Droppy设计上为单用户网络存储程序,可建立多个用户但是文件系统无分隔。在web界面中可以添加删除用户,不过初始的droppy账户需要在/srv/droppy/config/db.json文件中删除
也可以使用Apache或Nginx反向代理来消除地址后的‘小尾巴’
Apache配置示例(未测试):
须加载模块 mod_headers, mod_proxy, mod_proxy_wstunnel, mod_remoteip, mod_rewrite, mod_ssl
Apache Configuration
NameVirtualHost *:80
<VirtualHost *:80>
ServerName droppy.example.com
Redirect permanent / https://droppy.example.com/
</VirtualHost>
NameVirtualHost *:443
<VirtualHost *:443>
ServerName droppy.example.com
ErrorLog /var/log/httpd/droppy.example.com.log
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/droppy.example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/droppy.example.com/privkey.pem
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/!/socket [NC]
RewriteRule /(.*) ws://127.0.0.1:8989/$1 [P,L]
RemoteIPHeader X-Forwarded-For
RequestHeader set X-Forwarded-Proto "https"
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8989/
ProxyPassReverse / http://127.0.0.1:8989/
</VirtualHost>
nginx配置示例:
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 180;
client_max_body_size 0;
sendfile on;
tcp_nodelay on;
gzip off;
upstream droppy {
server 127.0.0.1:8989;
keepalive 32;
}
server {
listen 80;
listen [::]:80;
server_name droppy.example.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name droppy.example.com;
access_log /var/log/nginx/droppy.example.com.log;
ssl_certificate /etc/letsencrypt/live/droppy.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/droppy.example.com/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/droppy.example.com/fullchain.pem;
location / {
proxy_pass http://droppy/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
No comments:
Post a Comment