NC Cloud 远程访问项目代码/文件/日志的解决方案

问题:位于公有云或海外地区的项目,如果远程查看代码,除了登录服务器外,需要其他查看代码的方式。 通过配置共享,由于运营商策略,会受限制,很大可能打不开。

已邀请:

借助开源工具:filebrowser

项目地址:https://github.com/filebrowser/filebrowser/releases


1、下载相应版本的程序包,解压后文件为filebrowser,赋予执行权限

2、配置

创建配置数据库:./filebrowser -d /etc/filebrowser.db config init


设置监听地址:./filebrowser -d /etc/filebrowser.db config set --address 0.0.0.0


设置监听端口:./filebrowser -d /etc/filebrowser.db config set --port 8081


设置云盘路径:./filebrowser -d /etc/filebrowser.db config set --root /root/test


设置语言环境:./filebrowser -d /etc/filebrowser.db config set --locale zh-cn


设置日志位置:./filebrowser -d /etc/filebrowser.db config set --log /var/log/filebrowser.log


添加一个用户:./filebrowser -d /etc/filebrowser.db users add root password --perm.admin,其中的root和password分别是用户名和密码,根据自己的需求更改。


配置修改好以后,就可以启动 File Browser 了,使用-d参数指定配置数据库路径。示例:./filebrowser -d /etc/filebrowser.db


打开浏览器访问你的IP:8081,登录你刚刚创建的用户名和密码就可以了。



配置成服务,及开机启动


后台启动 并开机自启


首先下载 File Browser 的 service 文件:curl https://diannaobos.com/gongju/config/filebrowser.service -o /lib/systemd/system/filebrowser.service


filebrowser.service文件如下


[Unit]

Description=File Browser

After=network.target

 

[Service]

ExecStart=/usr/local/bin/filebrowser -d /etc/filebrowser.db

 

[Install]

WantedBy=multi-user.target

如果你的运行命令不是/usr/local/bin/filebrowser -d /etc/filebrowser.db,需要对 service 文件进行修改,将文件的 ExecStart 改为你的运行命令,更改完成后需要输入systemctl daemon-reload。


运行:systemctl start filebrowser.service


停止运行:systemctl stop filebrowser.service


开机启动:systemctl enable filebrowser.service


取消开机启动:systemctl disable filebrowser.service


查看运行状态:systemctl status filebrowser.service

要回复问题请先登录注册