add file
Change-Id: I49ce6d06ec46cbe679e4b8771031461047c704bb
diff --git a/nginx.conf b/nginx.conf
index dd6cedc..d06c697 100644
--- a/nginx.conf
+++ b/nginx.conf
@@ -1,4 +1,5 @@
worker_processes 1;
+
events { worker_connections 1024; }
http {
@@ -9,12 +10,47 @@
keepalive_timeout 65;
server {
- listen 8082;
+ 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';
+ }
}
}