Spaces:
Sleeping
Sleeping
Commit ·
e48ff69
1
Parent(s): 5d369bb
add file.
Browse files- nginx/mime.types +99 -0
- nginx/nginx.conf +50 -10
- scripts/start.sh +6 -4
nginx/mime.types
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
types {
|
| 3 |
+
text/html html htm shtml;
|
| 4 |
+
text/css css;
|
| 5 |
+
text/xml xml;
|
| 6 |
+
image/gif gif;
|
| 7 |
+
image/jpeg jpeg jpg;
|
| 8 |
+
application/javascript js;
|
| 9 |
+
application/atom+xml atom;
|
| 10 |
+
application/rss+xml rss;
|
| 11 |
+
|
| 12 |
+
text/mathml mml;
|
| 13 |
+
text/plain txt;
|
| 14 |
+
text/vnd.sun.j2me.app-descriptor jad;
|
| 15 |
+
text/vnd.wap.wml wml;
|
| 16 |
+
text/x-component htc;
|
| 17 |
+
|
| 18 |
+
image/avif avif;
|
| 19 |
+
image/png png;
|
| 20 |
+
image/svg+xml svg svgz;
|
| 21 |
+
image/tiff tif tiff;
|
| 22 |
+
image/vnd.wap.wbmp wbmp;
|
| 23 |
+
image/webp webp;
|
| 24 |
+
image/x-icon ico;
|
| 25 |
+
image/x-jng jng;
|
| 26 |
+
image/x-ms-bmp bmp;
|
| 27 |
+
|
| 28 |
+
font/woff woff;
|
| 29 |
+
font/woff2 woff2;
|
| 30 |
+
|
| 31 |
+
application/java-archive jar war ear;
|
| 32 |
+
application/json json;
|
| 33 |
+
application/mac-binhex40 hqx;
|
| 34 |
+
application/msword doc;
|
| 35 |
+
application/pdf pdf;
|
| 36 |
+
application/postscript ps eps ai;
|
| 37 |
+
application/rtf rtf;
|
| 38 |
+
application/vnd.apple.mpegurl m3u8;
|
| 39 |
+
application/vnd.google-earth.kml+xml kml;
|
| 40 |
+
application/vnd.google-earth.kmz kmz;
|
| 41 |
+
application/vnd.ms-excel xls;
|
| 42 |
+
application/vnd.ms-fontobject eot;
|
| 43 |
+
application/vnd.ms-powerpoint ppt;
|
| 44 |
+
application/vnd.oasis.opendocument.graphics odg;
|
| 45 |
+
application/vnd.oasis.opendocument.presentation odp;
|
| 46 |
+
application/vnd.oasis.opendocument.spreadsheet ods;
|
| 47 |
+
application/vnd.oasis.opendocument.text odt;
|
| 48 |
+
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
| 49 |
+
pptx;
|
| 50 |
+
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
| 51 |
+
xlsx;
|
| 52 |
+
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
| 53 |
+
docx;
|
| 54 |
+
application/vnd.wap.wmlc wmlc;
|
| 55 |
+
application/wasm wasm;
|
| 56 |
+
application/x-7z-compressed 7z;
|
| 57 |
+
application/x-cocoa cco;
|
| 58 |
+
application/x-java-archive-diff jardiff;
|
| 59 |
+
application/x-java-jnlp-file jnlp;
|
| 60 |
+
application/x-makeself run;
|
| 61 |
+
application/x-perl pl pm;
|
| 62 |
+
application/x-pilot prc pdb;
|
| 63 |
+
application/x-rar-compressed rar;
|
| 64 |
+
application/x-redhat-package-manager rpm;
|
| 65 |
+
application/x-sea sea;
|
| 66 |
+
application/x-shockwave-flash swf;
|
| 67 |
+
application/x-stuffit sit;
|
| 68 |
+
application/x-tcl tcl tk;
|
| 69 |
+
application/x-x509-ca-cert der pem crt;
|
| 70 |
+
application/x-xpinstall xpi;
|
| 71 |
+
application/xhtml+xml xhtml;
|
| 72 |
+
application/xspf+xml xspf;
|
| 73 |
+
application/zip zip;
|
| 74 |
+
|
| 75 |
+
application/octet-stream bin exe dll;
|
| 76 |
+
application/octet-stream deb;
|
| 77 |
+
application/octet-stream dmg;
|
| 78 |
+
application/octet-stream iso img;
|
| 79 |
+
application/octet-stream msi msp msm;
|
| 80 |
+
|
| 81 |
+
audio/midi mid midi kar;
|
| 82 |
+
audio/mpeg mp3;
|
| 83 |
+
audio/ogg ogg;
|
| 84 |
+
audio/x-m4a m4a;
|
| 85 |
+
audio/x-realaudio ra;
|
| 86 |
+
|
| 87 |
+
video/3gpp 3gpp 3gp;
|
| 88 |
+
video/mp2t ts;
|
| 89 |
+
video/mp4 mp4;
|
| 90 |
+
video/mpeg mpeg mpg;
|
| 91 |
+
video/quicktime mov;
|
| 92 |
+
video/webm webm;
|
| 93 |
+
video/x-flv flv;
|
| 94 |
+
video/x-m4v m4v;
|
| 95 |
+
video/x-mng mng;
|
| 96 |
+
video/x-ms-asf asx asf;
|
| 97 |
+
video/x-ms-wmv wmv;
|
| 98 |
+
video/x-msvideo avi;
|
| 99 |
+
}
|
nginx/nginx.conf
CHANGED
|
@@ -1,23 +1,63 @@
|
|
|
|
|
|
|
|
| 1 |
events {
|
| 2 |
-
worker_connections
|
|
|
|
| 3 |
}
|
| 4 |
|
| 5 |
http {
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
server localhost:8000;
|
| 8 |
}
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
server {
|
| 11 |
listen 7860;
|
| 12 |
server_name localhost;
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
location /static/ {
|
| 16 |
alias /app/static/;
|
| 17 |
expires 30d;
|
| 18 |
add_header Cache-Control "public, immutable";
|
| 19 |
}
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
# Django 媒体文件
|
| 22 |
location /media/ {
|
| 23 |
alias /app/django_app/media/;
|
|
@@ -53,12 +93,12 @@ http {
|
|
| 53 |
}
|
| 54 |
|
| 55 |
# 根路径
|
| 56 |
-
location / {
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
}
|
| 63 |
}
|
| 64 |
}
|
|
|
|
| 1 |
+
worker_processes auto;
|
| 2 |
+
|
| 3 |
events {
|
| 4 |
+
worker_connections 1024;
|
| 5 |
+
accept_mutex on;
|
| 6 |
}
|
| 7 |
|
| 8 |
http {
|
| 9 |
+
include mime.types;
|
| 10 |
+
|
| 11 |
+
upstream fastapi {
|
| 12 |
server localhost:8000;
|
| 13 |
}
|
| 14 |
|
| 15 |
+
upstream django {
|
| 16 |
+
server localhost:8001;
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
server {
|
| 20 |
listen 7860;
|
| 21 |
server_name localhost;
|
| 22 |
|
| 23 |
+
location /root {
|
| 24 |
+
alias "/app";
|
| 25 |
+
charset utf-8;
|
| 26 |
+
autoindex on;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
location /status {
|
| 30 |
+
# nginx status
|
| 31 |
+
stub_status on;
|
| 32 |
+
access_log off;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
# 静态文件
|
| 36 |
location /static/ {
|
| 37 |
alias /app/static/;
|
| 38 |
expires 30d;
|
| 39 |
add_header Cache-Control "public, immutable";
|
| 40 |
}
|
| 41 |
|
| 42 |
+
# API 路由
|
| 43 |
+
location /fastapi/ {
|
| 44 |
+
proxy_pass http://fastapi;
|
| 45 |
+
proxy_set_header Host $host;
|
| 46 |
+
proxy_set_header X-Real-IP $remote_addr;
|
| 47 |
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 48 |
+
proxy_set_header X-Forwarded-Proto $scheme;
|
| 49 |
+
|
| 50 |
+
# WebSocket 支持
|
| 51 |
+
proxy_http_version 1.1;
|
| 52 |
+
proxy_set_header Upgrade $http_upgrade;
|
| 53 |
+
proxy_set_header Connection "upgrade";
|
| 54 |
+
|
| 55 |
+
# 超时设置
|
| 56 |
+
proxy_connect_timeout 60s;
|
| 57 |
+
proxy_send_timeout 60s;
|
| 58 |
+
proxy_read_timeout 60s;
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
# Django 媒体文件
|
| 62 |
location /media/ {
|
| 63 |
alias /app/django_app/media/;
|
|
|
|
| 93 |
}
|
| 94 |
|
| 95 |
# 根路径
|
| 96 |
+
#location / {
|
| 97 |
+
# proxy_pass http://django;
|
| 98 |
+
# proxy_set_header Host $host;
|
| 99 |
+
# proxy_set_header X-Real-IP $remote_addr;
|
| 100 |
+
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
| 101 |
+
# proxy_set_header X-Forwarded-Proto $scheme;
|
| 102 |
+
#}
|
| 103 |
}
|
| 104 |
}
|
scripts/start.sh
CHANGED
|
@@ -5,11 +5,13 @@
|
|
| 5 |
#export DJANGO_SETTINGS_MODULE=myproject.settings
|
| 6 |
|
| 7 |
echo "Server beginning ..."
|
|
|
|
| 8 |
echo "Current Directory: $(pwd)"; echo "CPU Info:"; lscpu; echo "Disk Usage:"; df -h; echo "Block Devices:"; lsblk
|
| 9 |
|
| 10 |
-
# 启动 Nginx
|
| 11 |
-
#nginx -g "daemon off;"
|
| 12 |
nginx -c "$(pwd)/nginx/nginx.conf"
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
| 15 |
echo "Server started ..."
|
|
|
|
| 5 |
#export DJANGO_SETTINGS_MODULE=myproject.settings
|
| 6 |
|
| 7 |
echo "Server beginning ..."
|
| 8 |
+
# 显示当前目录、CPU信息、磁盘使用情况和块设备
|
| 9 |
echo "Current Directory: $(pwd)"; echo "CPU Info:"; lscpu; echo "Disk Usage:"; df -h; echo "Block Devices:"; lsblk
|
| 10 |
|
| 11 |
+
# 启动 Nginx // -g "daemon off;"
|
|
|
|
| 12 |
nginx -c "$(pwd)/nginx/nginx.conf"
|
| 13 |
+
|
| 14 |
+
# 启动 FastAPI // --workers 3
|
| 15 |
+
uvicorn app:app --reload --host 127.0.0.1 --port 8000 --log-level info
|
| 16 |
+
|
| 17 |
echo "Server started ..."
|