server { listen 8080; server_name _; root /usr/share/nginx/html; index index.html; server_tokens off; client_max_body_size 26m; add_header X-Content-Type-Options nosniff always; add_header Referrer-Policy strict-origin-when-cross-origin always; add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data: https:; connect-src 'self'; frame-ancestors 'none'; base-uri 'self'; form-action 'self'" always; # Oversized uploads are answered in the same JSON shape as the API instead of nginx's HTML page. error_page 413 = @upload_too_large; location @upload_too_large { default_type application/json; return 413 '{"message":"单文件不能超过 25MiB"}'; } location /api/public/extensions/plugin-frame/ { # This response carries the backend's sandbox policy. The app shell remains non-frameable. add_header X-Content-Type-Options nosniff always; proxy_pass http://backend:8080; proxy_http_version 1.1; proxy_set_header Host $host; # Overwrite rather than append: a client-supplied value must never reach the backend. The # backend only reads these when the direct peer is a trusted proxy. proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; } location /api/ { proxy_pass http://backend:8080; proxy_http_version 1.1; proxy_set_header Host $host; # Overwrite rather than append: a client-supplied value must never reach the backend. The # backend only trusts these when the direct peer is a private/loopback proxy address. proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Real-IP $remote_addr; } location / { try_files $uri $uri/ /index.html; } }