server {
    listen 6688;
    server_name 139.224.145.34;

    # 处理前端静态资源（Vue应用）
    location / {
        root   /usr/share/nginx/html;
        index  index.html;
        try_files $uri $uri/ /index.html; # 处理Vue路由history模式
        if ($request_method = OPTIONS) {
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE, OPTIONS';
            add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
            add_header 'Access-Control-Max-Age' 1728000;
            add_header 'Content-Type' 'text/plain charset=UTF-8';
            add_header 'Content-Length' 0;
            return 204;
        }

        limit_except GET POST PUT DELETE OPTIONS {
            deny all;
        }
    }

    # 代理后端API请求 - 使用更具体的路径
    location /api/ {
        proxy_buffer_size 1024k; #设置代理服务器（nginx）保存用户头信息的缓冲区大小
        proxy_buffers 16 1024k; #proxy_buffers缓冲区，网页平均在32k以下的设置
        proxy_busy_buffers_size 2048k; #高负荷下缓冲大小（proxy_buffers*2）
        proxy_temp_file_write_size 2048k; #设定缓存文件夹大小，大于这个值，将从upstream服务器传
        proxy_pass http://139.224.145.34:9002/;
    }

    # 可能需要代理其他后端服务
    # location /other-service/ {
    #     proxy_pass http://other-service:port/;
    # }
}
