I'm using Nginx as Reverse Proxy for my App Server.
The App Server receives file download requests via this route:
/files/:id
Then the app finds the file path on the File System i.e. /path/to/file/with/id and responds with the file contents.
I don't want to expose the file path to the user.
Is there a way to inform Nginx of the file's path so Nginx can handle the file download for the user, instead of my app server, I don't want to use Nginx as only a reverse proxy or a cache server, I need more of a app server from Nginx.
Overview:
Want to switch from this architecture:
[nodejs/express]> file contents [nginx]> file contents [browser]
to this architecture:
[nodejs/express]> file info [nginx]> file contents [browser]
file info:
path
mimetype
originalname
Nginx has to tell the browser about the originalname and mimetype of the file. the file name is hashed in the path and there's no sign of its mimetype in the file name, so I have to use the file info returned from the app server.