nginx

How to Restrict Access to a Static File in Angular/NGINX Server by Direct URI Access


We have an Angular application deployed on an NGINX server. Inside the assets folder, I have a subfolder named configuration which contains a file named configuration.json.

We load this configuration.json file into my Angular application using an HTTP call. However, the issue arises in the production environment:

The HTTP call appears in the Network tab of the browser's developer tools. If someone copies the request URL and pastes it into the browser, they can directly access the configuration.json file.

Requirement:

Environment:

What is the best approach to secure this file? Can it be achieved using NGINX configurations, or another method?

Thank you in advance for your help!


Solution

  • This depends on what production means for you or your organisation: