搭建一个web页面访问的FTP服务器
github官网地址
vsftpd 程序搭建跳转地址
vsftpd 搭建完成之后,开始搭建 ftp-web
下载运行该项目需要 Node.js v4+ 才能运行。# node 版本为 v16.20.2
node -v
v16.20.2git clone https://github.com/liuqi6908/ftp-web-client.git
cd ftp-web-client
npm install
npm start 或 node index.js注意事项
上传文件上传文件时使用 $.ajax() 携带 formData 参数发送 post 请求,但在新版本的 Node.js 中可能会出现报错:TypeError: os.tmpDir is not a function这是因为在新版本的 Node.js 中 os.tmpDir() 已被弃用,要找到指定位置将其修改为 os.tmpdir()
没改文件之前报错
修改文件
vim node_modules/multiparty/index.js
// 注销
// self.uploadDir = options.uploadDir || os.tmpDir();
// 修改为如下self.uploadDir = options.uploadDir || os.tmpdir();# 启动程序
npm start
访问
http://192.168.244.129:3000
添加 nginx 转发
upstream ftpd-backend {server 192.168.244.129:3000;
}server {listen 80;server_name ftpd.com;
# keepalive_timeout 70;access_log /var/log/nginx/ftpd-access.log main;error_log /var/log/nginx/ftpd-error.log;location / {client_max_body_size 1024M;proxy_pass http://ftpd-backend;proxy_buffering off;proxy_request_buffering off;proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_set_header Host $host;proxy_set_header X-Forwarded-For $remote_addr;}
}
重启 nginx
访问 nginx
http://ftpd.com