| worker_processes 1; |
| |
| events { worker_connections 1024; } |
| |
| http { |
| include mime.types; |
| default_type application/octet-stream; |
| |
| sendfile on; |
| keepalive_timeout 65; |
| |
| server { |
| listen 5009; |
| |
| # 支持 CORS 的全局选项处理(可选) |
| if ($request_method = OPTIONS) { |
| add_header Access-Control-Allow-Origin *; |
| add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE'; |
| add_header Access-Control-Allow-Headers 'Origin, Content-Type, Accept, Authorization'; |
| add_header Access-Control-Max-Age 3600; |
| return 204; |
| } |
| |
| # 1. 代理静态资源:如 http://localhost/static/index.html |
| location /upload/ { |
| alias /app/upload/; |
| autoindex on; |
| } |
| |
| # 反向代理 /api 到 localhost:8080 |
| location /api/ { |
| proxy_pass http://localhost:8080/; |
| proxy_set_header Host $host; |
| proxy_set_header X-Real-IP $remote_addr; |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| |
| # CORS headers |
| add_header Access-Control-Allow-Origin *; |
| add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE'; |
| add_header Access-Control-Allow-Headers 'Origin, Content-Type, Accept, Authorization'; |
| } |
| |
| # 反向代理 /tracker 到 localhost:6969/announce |
| location /tracker { |
| proxy_pass http://localhost:6969/announce; |
| proxy_set_header Host $host; |
| proxy_set_header X-Real-IP $remote_addr; |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| |
| # CORS headers |
| add_header Access-Control-Allow-Origin *; |
| add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS, PUT, DELETE'; |
| add_header Access-Control-Allow-Headers 'Origin, Content-Type, Accept, Authorization'; |
| } |
| } |
| } |