Merge branch '1-413-request-entity-too-large' into pre-release
This commit is contained in:
@@ -96,6 +96,7 @@ const upload = multer({
|
|||||||
dest: uploadDir,
|
dest: uploadDir,
|
||||||
limits: {
|
limits: {
|
||||||
fileSize: 100 * 1024 * 1024, // 100MB limit
|
fileSize: 100 * 1024 * 1024, // 100MB limit
|
||||||
|
files: 1, // Only one file per upload
|
||||||
},
|
},
|
||||||
fileFilter: (req, file, cb) => {
|
fileFilter: (req, file, cb) => {
|
||||||
// Only allow .db files for SQLite imports
|
// Only allow .db files for SQLite imports
|
||||||
@@ -115,6 +116,22 @@ app.use(
|
|||||||
app.use(express.json({ limit: "50mb" }));
|
app.use(express.json({ limit: "50mb" }));
|
||||||
app.use(express.urlencoded({ extended: true, limit: "50mb" }));
|
app.use(express.urlencoded({ extended: true, limit: "50mb" }));
|
||||||
|
|
||||||
|
// Log large requests for monitoring and debugging
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
const contentLength = req.headers["content-length"];
|
||||||
|
if (contentLength) {
|
||||||
|
const sizeInMB = parseInt(contentLength, 10) / 1024 / 1024;
|
||||||
|
if (sizeInMB > 10) {
|
||||||
|
console.log(
|
||||||
|
`[LARGE REQUEST] ${req.method} ${req.path} - ${sizeInMB.toFixed(
|
||||||
|
2
|
||||||
|
)}MB - Content-Length: ${contentLength} bytes`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
// Security middleware - Add security headers
|
// Security middleware - Add security headers
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
res.setHeader("X-Content-Type-Options", "nosniff");
|
res.setHeader("X-Content-Type-Options", "nosniff");
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ http {
|
|||||||
gzip_vary on;
|
gzip_vary on;
|
||||||
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
|
||||||
|
|
||||||
|
# Set maximum request body size to 50MB to handle large drawings with embedded images
|
||||||
|
client_max_body_size 50M;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name localhost;
|
server_name localhost;
|
||||||
@@ -29,6 +32,18 @@ http {
|
|||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
# Buffer and timeout settings for large payloads
|
||||||
|
proxy_buffering on;
|
||||||
|
proxy_buffer_size 4k;
|
||||||
|
proxy_buffers 8 4k;
|
||||||
|
proxy_busy_buffers_size 8k;
|
||||||
|
client_body_buffer_size 128k;
|
||||||
|
|
||||||
|
# Timeouts for large uploads (300 seconds)
|
||||||
|
proxy_connect_timeout 300s;
|
||||||
|
proxy_send_timeout 300s;
|
||||||
|
proxy_read_timeout 300s;
|
||||||
}
|
}
|
||||||
|
|
||||||
# WebSocket proxy for Socket.IO
|
# WebSocket proxy for Socket.IO
|
||||||
|
|||||||
Reference in New Issue
Block a user