cefac8cc4e
- Increase proxy buffer sizes to prevent upstream image responses being buffered to temporary files (16k header + 8x256k body + 512k busy) - Add env_file to frontend service in docker-compose.dev.yml for LOG_LEVEL - Normalize LOG_LEVEL in nginx-entrypoint.sh (case-insensitive, trim whitespace) - Add startup logging showing LOG_LEVEL → access_log mapping Closes #226
54 lines
1.8 KiB
Nginx Configuration File
54 lines
1.8 KiB
Nginx Configuration File
server {
|
|
# Port 8080 for unprivileged nginx (non-root)
|
|
listen 8080;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Access log control (suppressed when LOG_LEVEL is warn or higher)
|
|
access_log ${NGINX_ACCESS_LOG};
|
|
|
|
# Security headers
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
|
|
# Allow larger file uploads (for medication images and data import/export)
|
|
client_max_body_size 50M;
|
|
|
|
location / {
|
|
try_files $uri /index.html;
|
|
}
|
|
|
|
location /api/ {
|
|
# Use variable for runtime DNS resolution (nginx resolves at startup by default)
|
|
# Docker embedded DNS (127.0.0.11) with 10s cache
|
|
resolver 127.0.0.11 valid=10s ipv6=off;
|
|
set $backend_upstream ${BACKEND_URL};
|
|
|
|
# Strip /api prefix (nginx doesn't auto-rewrite when using variables in proxy_pass)
|
|
rewrite ^/api/(.*)$ /$1 break;
|
|
proxy_pass http://$backend_upstream;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# Pass cookies through
|
|
proxy_pass_header Set-Cookie;
|
|
proxy_cookie_path / /;
|
|
|
|
# Timeout for uploads
|
|
proxy_read_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
|
|
# Increase proxy buffers to avoid buffering images/responses to temp files
|
|
# Default is 8 x 4k/8k which is too small for medication images
|
|
proxy_buffer_size 16k;
|
|
proxy_buffers 8 256k;
|
|
proxy_busy_buffers_size 512k;
|
|
}
|
|
}
|