charles_c há 5 meses atrás
pai
commit
aded67ddba
3 ficheiros alterados com 7 adições e 5 exclusões
  1. 1 1
      Dockerfile.prod
  2. 6 0
      nginx/default.conf
  3. 0 4
      src/app/api/upload/route.js

+ 1 - 1
Dockerfile.prod

@@ -66,7 +66,7 @@ USER root
 RUN chmod 777 /app/public/uploads
 
 # 设置 umask
-RUN echo "umask 0002" >> /home/nextjs/.bashrc
+# RUN echo "umask 0002" >> /home/nextjs/.bashrc
 
 # 设置为非 root 用户
 USER nextjs

+ 6 - 0
nginx/default.conf

@@ -20,6 +20,12 @@ server {
         proxy_read_timeout 60s;
     }
 
+    location /uploads {
+        alias /app/public/uploads;
+        try_files $uri $uri/ =404;
+        add_header X-Debug-Message "$document_root$uri" always;
+    }
+
     # 添加健康检查路由
     location /health {
         access_log off;

+ 0 - 4
src/app/api/upload/route.js

@@ -1,5 +1,4 @@
 import { writeFile } from "fs/promises";
-import { chmod } from "fs/promises";
 import { NextResponse } from "next/server";
 import path from "path";
 import { setCORSHeaders } from "../../lib/apiUtils";
@@ -26,9 +25,6 @@ export async function POST(request) {
 
     await writeFile(filepath, buffer);
 
-    // 设置文件权限为 0755 (rwxr-xr-x)
-    await chmod(filepath, 0o755);
-
     const response = NextResponse.json({
       success: true,
       filename,