disable_symlinks
The `disable_symlinks` directive controls whether symbolic links are allowed in the file system level when processing requests.
Description
The disable_symlinks directive in NGINX can be configured to restrict the following symbolic link behaviors: it can either allow or disallow the use of symbolic links to files within specified contexts such as http, server, and location. When set, this directive can enhance security by preventing access to files that may be pointed to by symbolic links that lie outside of the intended document root or location block.
This directive accepts one or two arguments. When only one argument is provided, it denotes whether symbolic links are disabled or not. A second argument can be provided to specify a directory or the type of symlink behavior permitted. This additional parameter enhances the granularity of control by allowing specific files or directories to be treated differently from others regarding symbolic links.
As a result, system administrators can secure their NGINX implementations by carefully configuring this directive to prevent possible security vulnerabilities caused by inadvertent access through symbolic links. It is also important to ensure that the configuration adheres to the principle of least privilege, to allow access only to necessary files.
Config Example
location /files {
disable_symlinks on;
}Misconfiguration can lead to 403 Forbidden errors if symlinks are used unintentionally.
If you enable symlink processing for a directory, verify that you do not expose sensitive files.