worker_processes 1; events { worker_connections 1024; } http { server { # Listen on port 80 listen 80; # Define the server name server_name localhost; # Root location block location / { # Serve static files from this directory root /usr/share/nginx/html; # Default index file index index.html; # Try to serve the file, if not found, serve index.html (for single-page applications) try_files $uri $uri/ /index.html; } # Location block for /upload endpoint location /upload { # Proxy the request to the backend service proxy_pass http://backend:8000/upload; # Include the common proxy headers 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; # Include the common CORS headers add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization'; } # Location block for /retrieve_from_path endpoint location /retrieve_from_path { # Proxy the request to the backend service proxy_pass http://backend:8000/retrieve_from_path; # Include the common proxy headers 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; # Include the common CORS headers add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'Origin, Content-Type, Accept, Authorization'; } # Error page handling error_page 500 502 503 504 /50x.html; # Location block for the custom error page location = /50x.html { # Serve the error page from this directory root /usr/share/nginx/html; } } }