Skip to main content

Static File Handling

Static file requests (to /static/...) are handled flexibly at the Nginx level. If a requested static file is not found, the request is passed to the webshop backend. This gives the webshop an opportunity to respond to missing file requests, for example by showing a fallback page or implementing custom logic if supported.

How It Works​

Nginx uses the following logic to handle /static requests:

try_files $uri $uri/ @fallback_static;

If the file cannot be found locally, the request is passed to the webshop using a fallback handler:

location @fallback_static {
proxy_pass http://<webshop_backend>;
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-Scheme $scheme;
proxy_set_header X-Request-ID $request_id;
}

This ensures that request context is preserved and the webshop can handle the request.

Key Benefits​

  • Enables the webshop to handle missing static file requests.
  • Allows for centralized handling of broken links or fallback behavior through the webshop logic.

Performance Considerations​

Routing missing static requests to the webshop introduces minimal additional load. Since most other routes already go through the webshop, the system is equipped to handle these fallbacks efficiently.