fix: #350 需要通过添加反代确保真实IP来源

This commit is contained in:
Lan
2025-05-28 23:29:13 +08:00
parent 40cb6768b7
commit ff0f057042
2 changed files with 68 additions and 4 deletions
+32 -1
View File
@@ -19,8 +19,8 @@
</div> </div>
## 🚀 更新计划 ## 🚀 更新计划
- [ ] 切片上传,同文件秒传,断点续传 - [ ] 切片上传,同文件秒传,断点续传
- [ ] 文件收集功能 - [ ] 文件收集功能
@@ -47,6 +47,7 @@ FileCodeBox 是一个基于 FastAPI + Vue3 开发的轻量级文件分享工具
</div> </div>
### 新版界面 ### 新版界面
<div align="center"> <div align="center">
<table> <table>
<tr> <tr>
@@ -69,6 +70,7 @@ FileCodeBox 是一个基于 FastAPI + Vue3 开发的轻量级文件分享工具
</div> </div>
### 经典界面 ### 经典界面
<div align="center"> <div align="center">
<table> <table>
<tr> <tr>
@@ -143,6 +145,7 @@ FileCodeBox 是一个基于 FastAPI + Vue3 开发的轻量级文件分享工具
- IP 限制上传次数 - IP 限制上传次数
- 错误次数限制 - 错误次数限制
- 文件过期机制 - 文件过期机制
</td> </td>
<td align="center"> <td align="center">
<h4>🎫 提取码分享</h4> <h4>🎫 提取码分享</h4>
@@ -188,11 +191,13 @@ FileCodeBox 是一个基于 FastAPI + Vue3 开发的轻量级文件分享工具
### Docker 部署 ### Docker 部署
#### Docker CLI #### Docker CLI
```bash ```bash
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
``` ```
#### Docker Compose #### Docker Compose
```yml ```yml
version: "3" version: "3"
services: services:
@@ -208,20 +213,35 @@ volumes:
external: false external: false
``` ```
### 配置反向代理(Nginx示例)
请注意,必须添加以下配置来确保正确处理客户端IP和代理请求:
```nginx
location / {
proxy_set_header X-Real-IP $remote_addr; # 设置真实客户端IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:12345;
}
```
### 手动部署 ### 手动部署
1. 克隆项目 1. 克隆项目
```bash ```bash
git clone https://github.com/vastsa/FileCodeBox.git git clone https://github.com/vastsa/FileCodeBox.git
``` ```
2. 安装依赖 2. 安装依赖
```bash ```bash
cd FileCodeBox cd FileCodeBox
pip install -r requirements.txt pip install -r requirements.txt
``` ```
3. 启动服务 3. 启动服务
```bash ```bash
python main.py python main.py
``` ```
@@ -229,17 +249,20 @@ python main.py
## 📖 使用说明 ## 📖 使用说明
### 分享文件 ### 分享文件
1. 打开网页,点击"分享文件" 1. 打开网页,点击"分享文件"
2. 选择或拖拽文件 2. 选择或拖拽文件
3. 设置过期时间和次数 3. 设置过期时间和次数
4. 获取提取码 4. 获取提取码
### 获取文件 ### 获取文件
1. 打开网页,输入提取码 1. 打开网页,输入提取码
2. 点击获取 2. 点击获取
3. 下载文件或查看文本 3. 下载文件或查看文本
### 管理面板 ### 管理面板
1. 访问 `/#/admin` 1. 访问 `/#/admin`
2. 输入管理员密码 `FileCodeBox2023` 2. 输入管理员密码 `FileCodeBox2023`
3. 管理文件和配置 3. 管理文件和配置
@@ -247,6 +270,7 @@ python main.py
## 🛠 开发指南 ## 🛠 开发指南
### 项目结构 ### 项目结构
``` ```
FileCodeBox/ FileCodeBox/
├── apps/ # 应用代码 ├── apps/ # 应用代码
@@ -258,18 +282,22 @@ FileCodeBox/
``` ```
### 开发环境 ### 开发环境
- Python 3.8+ - Python 3.8+
- Node.js 14+ - Node.js 14+
- Vue 3 - Vue 3
- FastAPI - FastAPI
### 本地开发 ### 本地开发
1. 后端开发 1. 后端开发
```bash ```bash
python main.py python main.py
``` ```
2. 前端开发 2. 前端开发
```bash ```bash
cd fcb-fronted cd fcb-fronted
npm install npm install
@@ -287,12 +315,15 @@ npm run dev
## ❓ 常见问题 ## ❓ 常见问题
### Q: 如何修改上传大小限制? ### Q: 如何修改上传大小限制?
A: 在管理面板中修改配置项 `uploadSize` A: 在管理面板中修改配置项 `uploadSize`
### Q: 如何配置存储引擎? ### Q: 如何配置存储引擎?
A: 在管理面板中选择存储引擎并配置相应参数 A: 在管理面板中选择存储引擎并配置相应参数
### Q: 如何备份数据? ### Q: 如何备份数据?
A: 备份 `data` 目录即可 A: 备份 `data` 目录即可
更多问题请访问 [Wiki](https://github.com/vastsa/FileCodeBox/wiki/常见问题) 更多问题请访问 [Wiki](https://github.com/vastsa/FileCodeBox/wiki/常见问题)
+36 -3
View File
@@ -21,7 +21,9 @@
## 📝 Introduction ## 📝 Introduction
FileCodeBox is a lightweight file sharing tool developed with FastAPI + Vue3. It allows users to share text and files easily, where recipients only need a passcode to retrieve the files, just like picking up a package from a delivery locker. FileCodeBox is a lightweight file sharing tool developed with FastAPI + Vue3. It allows users to share text and files
easily, where recipients only need a passcode to retrieve the files, just like picking up a package from a delivery
locker.
## 🖼️ Preview ## 🖼️ Preview
@@ -41,6 +43,7 @@ FileCodeBox is a lightweight file sharing tool developed with FastAPI + Vue3. It
</div> </div>
### New Interface ### New Interface
<div align="center"> <div align="center">
<table> <table>
<tr> <tr>
@@ -63,6 +66,7 @@ FileCodeBox is a lightweight file sharing tool developed with FastAPI + Vue3. It
</div> </div>
### Classic Interface ### Classic Interface
<div align="center"> <div align="center">
<table> <table>
<tr> <tr>
@@ -137,6 +141,7 @@ Support text and various file types
- IP upload limits - IP upload limits
- Error attempt limits - Error attempt limits
- File expiration - File expiration
</td> </td>
<td align="center"> <td align="center">
<h4>🎫 Passcode Sharing</h4> <h4>🎫 Passcode Sharing</h4>
@@ -181,13 +186,14 @@ Command-line download
### Docker Deployment ### Docker Deployment
#### Docker CLI #### Docker CLI
```bash ```bash
docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta docker run -d --restart=always -p 12345:12345 -v /opt/FileCodeBox/:/app/data --name filecodebox lanol/filecodebox:beta
``` ```
#### Docker Compose #### Docker Compose
```yml ```yml
version: "3" version: "3"
services: services:
@@ -203,20 +209,35 @@ volumes:
external: false external: false
``` ```
### Configure reverse proxy (Nginx example)
Please note that the following configurations must be added to ensure proper handling of client IP and proxy requests:
```nginx
location / {
proxy_set_header X-Real-IP $remote_addr; #Set real client IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:12345 ;
}
```
### Manual Deployment ### Manual Deployment
1. Clone the repository 1. Clone the repository
```bash ```bash
git clone https://github.com/vastsa/FileCodeBox.git git clone https://github.com/vastsa/FileCodeBox.git
``` ```
2. Install dependencies 2. Install dependencies
```bash ```bash
cd FileCodeBox cd FileCodeBox
pip install -r requirements.txt pip install -r requirements.txt
``` ```
3. Start the service 3. Start the service
```bash ```bash
python main.py python main.py
``` ```
@@ -224,17 +245,20 @@ python main.py
## 📖 Usage Guide ## 📖 Usage Guide
### Share Files ### Share Files
1. Open the website, click "Share File" 1. Open the website, click "Share File"
2. Select or drag files 2. Select or drag files
3. Set expiration time and count 3. Set expiration time and count
4. Get the passcode 4. Get the passcode
### Retrieve Files ### Retrieve Files
1. Open the website, enter passcode 1. Open the website, enter passcode
2. Click retrieve 2. Click retrieve
3. Download file or view text 3. Download file or view text
### Admin Panel ### Admin Panel
1. Visit `/admin` 1. Visit `/admin`
2. Enter admin password 2. Enter admin password
3. Manage files and settings 3. Manage files and settings
@@ -242,6 +266,7 @@ python main.py
## 🛠 Development Guide ## 🛠 Development Guide
### Project Structure ### Project Structure
``` ```
FileCodeBox/ FileCodeBox/
├── apps/ # Application code ├── apps/ # Application code
@@ -253,18 +278,22 @@ FileCodeBox/
``` ```
### Development Environment ### Development Environment
- Python 3.8+ - Python 3.8+
- Node.js 14+ - Node.js 14+
- Vue 3 - Vue 3
- FastAPI - FastAPI
### Local Development ### Local Development
1. Backend development 1. Backend development
```bash ```bash
python main.py python main.py
``` ```
2. Frontend development 2. Frontend development
```bash ```bash
cd fcb-fronted cd fcb-fronted
npm install npm install
@@ -282,12 +311,15 @@ npm run dev
## ❓ FAQ ## ❓ FAQ
### Q: How to modify upload size limit? ### Q: How to modify upload size limit?
A: Change `uploadSize` in admin panel A: Change `uploadSize` in admin panel
### Q: How to configure storage engine? ### Q: How to configure storage engine?
A: Select storage engine and configure parameters in admin panel A: Select storage engine and configure parameters in admin panel
### Q: How to backup data? ### Q: How to backup data?
A: Backup the `data` directory A: Backup the `data` directory
For more questions, visit [Wiki](https://github.com/vastsa/FileCodeBox/wiki/常见问题) For more questions, visit [Wiki](https://github.com/vastsa/FileCodeBox/wiki/常见问题)
@@ -304,4 +336,5 @@ For more questions, visit [Wiki](https://github.com/vastsa/FileCodeBox/wiki/常
## 📜 Disclaimer ## 📜 Disclaimer
This project is open-source for learning purposes only. It should not be used for any illegal purposes. The author is not responsible for any consequences. Please retain the project address and copyright information when using it. This project is open-source for learning purposes only. It should not be used for any illegal purposes. The author is
not responsible for any consequences. Please retain the project address and copyright information when using it.