create_full_put_path
The 'create_full_put_path' directive enables the creation of full directory paths for PUT requests.
Description
The 'create_full_put_path' directive is a configuration option in NGINX that specifies whether to create full paths for client-uploaded files during PUT requests. When set to 'on', NGINX will not only create the target file specified in a PUT request but will also ensure that all directories leading up to that target file exist. This becomes particularly important in scenarios where clients may attempt to upload files to paths that may not have been previously created on the server, thereby enhancing the handling of file uploads by ensuring that the necessary directory structure is in place.
When the directive is set to 'off' (the default), NGINX will respond with a 403 Forbidden error if a directory specified in the PUT path does not exist. However, if 'create_full_put_path' is enabled, during the PUT operation, if intermediate directories are missing, NGINX will attempt to create them automatically, allowing the upload to succeed. This can be a significant convenience when managing file uploads and can help prevent failures due to missing directories when clients use PUT requests.
In terms of expected behavior, when this directive is placed within the http, server, or location contexts, it functions uniformly across the board, making it flexible to various configurations where file uploads are expected.
Config Example
location /uploads {
create_full_put_path on;
root /var/www;
}Ensure that the NGINX worker user has appropriate permissions to create directories.
Be cautious with auto-creation of directories to avoid unintentional exposure of sensitive file paths.
Remember to verify the inclusion of this directive within an appropriate context.