Step 1. Locate nginx.conf:
The nginx.conf file typically resides in the Nginx configuration directory. Example path: /etc/nginx/nginx.conf.
Open nginx.conf – Use a text editor or command-line tools (vi, nano, etc.) to open the file.
Step 2. Locate the server Block:
Find the server block where you want to add the new location block. Ensure it’s within the appropriate context.
Step 3. Insert the Location Block:
Add the following code snippet inside the server block, replacing {website} with your actual website name:
location ~ ^/wp-content/uploads/upf-docs/(.*)$ {
rewrite ^/wp-content/uploads/upf-docs/(.*)$ https://www.example.com/?file=$1 last;
}
Replace example.com in the code snippet with your website URL .
Step 4. Save Changes:
Save the nginx.conf file after adding the new location block.
Now test this by pasting the URL to a file in a private browser window and it should give a permission error.