blob: d06c697bb6b566c7b50d76d69d77e17c7a23768a [file] [log] [blame]
Seamher147b16c2025-06-03 16:53:49 +08001worker_processes 1;
Seamher5ff35f82025-06-09 01:23:27 +08002
Seamher147b16c2025-06-03 16:53:49 +08003events { worker_connections 1024; }
4
5http {
6 include mime.types;
7 default_type application/octet-stream;
8
9 sendfile on;
10 keepalive_timeout 65;
11
12 server {
Seamher5ff35f82025-06-09 01:23:27 +080013 listen 5009;
14
15 # 支持 CORS 的全局选项处理(可选)
16 if ($request_method = OPTIONS) {
17 add_header Access-Control-Allow-Origin *;
18 add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE';
19 add_header Access-Control-Allow-Headers 'Origin, Content-Type, Accept, Authorization';
20 add_header Access-Control-Max-Age 3600;
21 return 204;
22 }
Seamher147b16c2025-06-03 16:53:49 +080023
24 # 1. 代理静态资源:如 http://localhost/static/index.html
25 location /upload/ {
26 alias /app/upload/;
27 autoindex on;
28 }
Seamher5ff35f82025-06-09 01:23:27 +080029
30 # 反向代理 /api 到 localhost:8080
31 location /api/ {
32 proxy_pass http://localhost:8080/;
33 proxy_set_header Host $host;
34 proxy_set_header X-Real-IP $remote_addr;
35 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
36
37 # CORS headers
38 add_header Access-Control-Allow-Origin *;
39 add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE';
40 add_header Access-Control-Allow-Headers 'Origin, Content-Type, Accept, Authorization';
41 }
42
43 # 反向代理 /tracker 到 localhost:6969/announce
44 location /tracker {
45 proxy_pass http://localhost:6969/announce;
46 proxy_set_header Host $host;
47 proxy_set_header X-Real-IP $remote_addr;
48 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
49
50 # CORS headers
51 add_header Access-Control-Allow-Origin *;
52 add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE';
53 add_header Access-Control-Allow-Headers 'Origin, Content-Type, Accept, Authorization';
54 }
Seamher147b16c2025-06-03 16:53:49 +080055 }
56}