Files
Warracker/nginx.conf
sassanix c267517de2 Fixed uploads to load the invoices
1. **Simplified nginx configuration:**
   - Changed from `root /data` back to `alias /data/uploads/` which is the correct way to map `/uploads/` to `/data/uploads/`
   - Removed potentially conflicting location blocks
   - Fixed the error handling to not redirect upload 404s to the index page

2. **Improved startup script:**
   - Added checking and reporting of directory permissions
   - Added explicit chmod during startup

3. **Simplified Flask route:**
   - Removed all the complex debugging code
   - Returned to a simple `send_from_directory` call

4. **Added a basic test file:**
   - Created ping.html to test basic nginx functionality
2025-03-03 07:59:44 -04:00

78 lines
2.3 KiB
Nginx Configuration File

server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
# Enable detailed error logging
error_log /var/log/nginx/error.log debug;
access_log /var/log/nginx/access.log;
# Enable gzip compression
gzip on;
gzip_types text/plain text/css application/javascript application/json;
# Add CORS headers
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
# A test location to debug directory paths
location = /test-uploads {
add_header Content-Type text/plain;
return 200 "Uploads directory exists: $document_root\n";
}
location / {
try_files $uri $uri/ /index.html;
}
# Proxy API requests to backend
location /api/ {
proxy_pass http://warracker:5000;
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;
}
# Simpler uploads location - using alias instead of root
location /uploads/ {
alias /data/uploads/;
autoindex on;
# Set appropriate MIME types
types {
image/png png PNG;
image/jpeg jpg jpeg JPG JPEG;
application/pdf pdf PDF;
text/plain txt TXT;
}
# Disable caching for testing
add_header Cache-Control "no-cache, no-store, must-revalidate";
add_header Pragma "no-cache";
add_header Expires "0";
}
# Cache static assets - skip uploads
location ~* \.(css|js|jpg|jpeg|png|gif|ico|svg)$ {
# Skip this location if the request is for /uploads/
if ($request_uri ~* "^/uploads/") {
return 404;
}
expires 7d;
add_header Cache-Control "public, max-age=604800";
}
# Don't redirect 404s for uploads to index.html
location ~ ^/uploads/ {
try_files $uri =404;
}
# Error handling - for everything except uploads
location / {
error_page 404 = /index.html;
}
}