From 053963d050b29dceb56c17c46413c06ba3c98329 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Tue, 10 Oct 2023 08:36:09 +0800 Subject: [PATCH] nginx conf --- nginx.conf | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 nginx.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 00000000..657eeb65 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,86 @@ +worker_processes auto; + +events { + worker_connections 1024; +} + + +http { + + sendfile on; + + keepalive_timeout 3600; + + server { + + include mime.types; + default_type application/octet-stream; + + listen 3000; + listen [::]:3000; + server_name moviepilot; + + location / { + # 主目录 + expires off; + add_header Cache-Control "no-cache, no-store, must-revalidate"; + root html; + try_files $uri $uri/ /index.html; + } + + location /assets { + # 静态资源 + expires 7d; + add_header Cache-Control "public"; + root html; + } + + location ~ ^/api/v1/system/(message|progress/) { + # SSE MIME类型设置 + default_type text/event-stream; + + # 禁用缓存 + add_header Cache-Control no-cache; + add_header X-Accel-Buffering no; + proxy_buffering off; + proxy_cache off; + + # 代理设置 + proxy_pass http://backend_api; + proxy_http_version 1.1; + proxy_set_header Connection ""; + 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_read_timeout 3600s; + } + + location /api { + # 后端API + proxy_pass http://backend_api; + rewrite ^.+mock-server/?(.*)$ /$1 break; + proxy_http_version 1.1; + proxy_buffering off; + proxy_cache off; + proxy_redirect off; + proxy_set_header Connection ""; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + proxy_set_header X-Nginx-Proxy true; + + # 超时设置 + proxy_read_timeout 600s; + } + } + + upstream backend_api { + # 后端API的地址和端口 + server 127.0.0.1:3001; + # 可以添加更多后端服务器作为负载均衡 + } + +}