Seamher | 147b16c | 2025-06-03 16:53:49 +0800 | [diff] [blame] | 1 | worker_processes 1; |
Seamher | 5ff35f8 | 2025-06-09 01:23:27 +0800 | [diff] [blame] | 2 | |
Seamher | 147b16c | 2025-06-03 16:53:49 +0800 | [diff] [blame] | 3 | events { worker_connections 1024; } |
| 4 | |
| 5 | http { |
| 6 | include mime.types; |
| 7 | default_type application/octet-stream; |
| 8 | |
| 9 | sendfile on; |
| 10 | keepalive_timeout 65; |
| 11 | |
| 12 | server { |
Seamher | 5ff35f8 | 2025-06-09 01:23:27 +0800 | [diff] [blame] | 13 | 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 | } |
Seamher | 147b16c | 2025-06-03 16:53:49 +0800 | [diff] [blame] | 23 | |
| 24 | # 1. 代理静态资源:如 http://localhost/static/index.html |
| 25 | location /upload/ { |
| 26 | alias /app/upload/; |
| 27 | autoindex on; |
| 28 | } |
Seamher | 5ff35f8 | 2025-06-09 01:23:27 +0800 | [diff] [blame] | 29 | |
| 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 | } |
Seamher | 147b16c | 2025-06-03 16:53:49 +0800 | [diff] [blame] | 55 | } |
| 56 | } |