Show external folder html content in django

These are static html files that are to be presented as-is? (along with their associated images, scripts and css)

You’ve got a couple different options here:

  • You can use the ngx_http_auth_request_module to pass a subrequest to Django for authorization, allowing nginx to serve the files. See Module ngx_http_auth_request_module)

  • You can use the X-Sendfile feature to have the request get passed through to Django, which then returns a response with the X-Accel-Redirect header. See X-Accel | NGINX and XSendfile | NGINX.

  • You can add whitenoise to your Django app to actually serve the static files. You would then either need to modify the middleware to perform a security check before serving the file, or add a security check as a separate middleware class before the whitenoise middleware.

  • Last, and definitely least, you could allow Django itself to serve the static files. See Managing static files (e.g. images, JavaScript, CSS) | Django documentation | Django. Note, from the docs:

This is not suitable for production use! For some common deployment strategies, see Deploying static files.