I got an idea for to write a simple script to create an Nginx config file based on a set of files that would be allowed to be run. In my case they would be .php files from an application. The script would simply create an Nginx config entry for every single .php file in a directory, where the .php files would be.
In my view specifying every single application file would prohibit unauthorized execution, and when the application in question is run very simply from said php files, it should be easy to implement in an Nginx config. Perhaps the script could also be able understand to set general ratelimits for user accessible php files and files that would never need to be seen by the user.
Thus how I see an ideal script, it would create config based on at least these properties:
- executable name, .php, .py, .pl etc
- folders not required to be directly accessible (but still create config based on every file in these folders)
- ratelimits per folder, or at least for the user facing files
I am asking the question in order to gather evidence for going further, and also since I couldn't readily find a script that would be directed at such config creation for nginx. (Maybe just because it is so easy to write..). Ultimately the goal is extra security, and thus I'm also seeking opinions on how such configuration of Nginx would affect it, and if it is a good idea at all.