伟大的更新:优化静态资源路径,加入Nginx配置,安全至上!

This commit is contained in:
张建平 2025-02-26 18:07:14 +08:00
parent 5802b36f46
commit a10a565f64
12 changed files with 52 additions and 10 deletions

3
.gitignore vendored
View File

@ -12,4 +12,5 @@ build/
docs/.cache/
.qodo
db.sqlite3
#pr_agent/
#pr_agent/
static/admin/

View File

@ -86,18 +86,18 @@ python manage.py runserver
## PR管理系统配置说明
![主页菜单](static/主页.png)
![主页菜单](static/md_image/主页.png)
所有配置均通过 Django admin 后台管理,主要包括:
- **AI 服务器**:配置 AI 服务接入信息。
![AI 服务器](static/AI配置.png)
![AI 服务器](static/md_image/AI配置.png)
- **Git 服务器**:配置与各 Git 服务的连接及 webhook 信息。
![Git 服务器](static/Git服务配置.png)
![Git 服务器](static/md_image/Git服务配置.png)
![项目配置](static/项目配置.png)
![项目配置](static/md_image/项目配置.png)
- **指令设置**:配置在 webhook 触发时需要执行的各项指令(例如代码审核、描述与改进)。
@ -107,15 +107,15 @@ python manage.py runserver
- **用户AccessToken** 配置Gitlab用户的AccessToken用于获取用户信息。
![用户AccessToken](static/gitlab_access.png)
![用户AccessToken](static/md_image/gitlab_access.png)
- **项目Secret** 配置Gitlab项目的Secret用于验证请求的合法性。
![项目Secret](static/项目Secret.png)
![项目Secret](static/md_image/项目Secret.png)
- **Webhook配置** 配置Gitlab项目的Webhook用于处理Gitlab的推送事件。
![Webhook配置](static/Webhook配置.png)
![Webhook配置](static/md_image/Webhook配置.png)
## 默认账号及 Git 服务器支持

View File

@ -1,4 +1,17 @@
services:
nginx:
image: nginx:latest
container_name: nginx
ports:
- "10008:80"
volumes:
- ./static/nginx:/etc/nginx/conf.d
- ./static/:/app/static
logging:
driver: "json-file"
options:
max-size: "50M"
max-file: "1"
# admin服务
backend:
image: pr_manager:latest

View File

@ -27,7 +27,7 @@ sys.path.insert(1, os.path.join(BASE_DIR, "apps/utils"))
SECRET_KEY = "django-insecure-$r6lfcq8rev&&=chw259o$0o7t-!!%clc2ahs3xg$^z+gkms76"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False
ALLOWED_HOSTS = ["*"]
@ -128,11 +128,17 @@ USE_L10N = True
USE_TZ = False
# 全局时间格式化
DATETIME_FORMAT = "Y-m-d H:i:sO"
date_format = 'Y-m-d'
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/5.1/howto/static-files/
STATIC_URL = "static/"
STATIC_URL = "/static/"
# 生产环境目录
STATIC_ROOT = BASE_DIR / "static"
# Default primary key field type
# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

View File

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

22
static/nginx/pr.conf Normal file
View File

@ -0,0 +1,22 @@
server {
listen 80;
server_name localhost;
client_max_body_size 512M;
keepalive_timeout 1800s;
sendfile on;
chunked_transfer_encoding on;
location /static {
alias /app/static/;
}
location / {
proxy_set_header Access-Control-Allow-Origin *;
proxy_set_header Access-Control-Allow-Methods *;
proxy_set_header Access-Control-Allow-Headers *;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://backend:18000;
}
}