更新部署

This commit is contained in:
ganweichong 2025-10-12 18:32:52 +08:00
parent a97d1b4cac
commit 893c0d0334
1 changed files with 98 additions and 0 deletions

98
nginx.conf Normal file
View File

@ -0,0 +1,98 @@
server {
listen 80;
server_name _;
client_max_body_size 5000m;
# 启用gzip压缩
gzip on;
gzip_min_length 2k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types
# text/html is always compressed by HttpGzipModule
text/css
text/javascript
text/xml
text/plain
text/x-component
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
font/truetype
font/opentype
application/vnd.ms-fontobject
application/x-httpd-php
image/jpeg
image/gif
image/png
image/svg+xml;
gzip_vary on;
# 前端静态页面
root /usr/share/nginx/html;
index index.html;
# 处理 Vue Router history 模式
location / {
try_files $uri $uri/ /index.html;
}
# 前端路径修改
location /selenium_web/ {
proxy_pass http://selenium-vue-container:80/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 后端 API 代理
location /selenium_api/ {
proxy_pass http://selenium-django-container:8000/;
# 基本身份头
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# SSE 关键配置
proxy_cache off; # 禁用缓存
proxy_buffering off; # 禁用缓冲(关键!)
proxy_http_version 1.1; # 使用 HTTP/1.1
proxy_set_header Connection ''; # 清除 Connection
# 超时设置(根据需要调整)
proxy_read_timeout 3600s; # 读取超时1小时根据实际需求调整
proxy_send_timeout 3600s; # 发送超时
# 可选:设置正确的 Content-Type如果后端未正确设置
# proxy_hide_header Content-Type;
add_header Content-Type "text/event-stream";
# 可选:允许跨域(如果前端和后端域名不同)
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
}
# 后端爬虫 API 代理
location /selenium_crawl_api/ {
proxy_pass http://selenium-crawl-container:5000/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# 静态文件
location /static1/ {
alias /app/static/;
}
# 媒体文件
location /media1/ {
alias /app/media/;
}
}