min_delete_depth
The `min_delete_depth` directive sets the minimum depth for directory deletions in the NGINX file system handling.
Description
The min_delete_depth directive is utilized in NGINX's file handling to specify the minimal directory depth that is necessary for deletion operations to proceed. When this directive is set, NGINX will only allow deletion of directories that have a depth greater than or equal to the specified level. This is particularly useful for preventing accidental deletions of root or top-level directories by enforcing a more stringent condition on deletion operations.
In NGINX's hierarchical configuration, the directory depth is calculated based on the number of slashes (/) in the path. For example, a path like /var/www/html has a depth of 2. The directive helps to safeguard against irreversible deletions by ensuring that only directories that meet the minimum depth criteria can be deleted. This way, administrators can mitigate risks associated with data loss while managing file structures on the server.
This directive can be set at multiple levels including http, server, and location, granting flexibility depending on the configuration needs. The value assigned to min_delete_depth must be a positive integer that correlates to the required directory depth for deletions to take place.
Config Example
http {
min_delete_depth 2;
}If set too high, it may prevent legitimate deletions of nested directories.
Not applicable if the depth of the target directory is less than the specified limit.