Nginx's 403 Forbidden errors indicates that you are requesting a resource file but Nginx does not allow you to view it.
403 Forbidden is just an HTTP status code, like 404,200 is not a technical error.
Which scenes need to return a 403 status code scenario?
1. The website prohibits specific users from accessing all content, for example: the site masks an IP access.
2. Access directory to prohibit directory browsing, example: Set AutoIndex off to access the directory.
3. User access to only intranet access files.
There are several common scenarios that need to return to 403 forbidden.
Because the server-side error configuration results in the desire not to
Returns 403 Forbidden when Nginx returns 403.
1. Permissions are not configured correctly
This is the most common reason why Nginx appears 403 forbidden.
To ensure that the files are executed correctly, Nginx requires both read access to the file and executable permissions for all of the files ' parent directories.
For example, when accessing/usr/local/nginx/html/image.jpg, Nginx requires both the Image.jpg file's readable permissions and the/,/usr,/usr/local,/usr/local/nginx,/usr/ The local/nginx/html can execute permissions.
Workaround: Set all parent directories to 755 permissions and set the file to 644 permissions to avoid incorrect permissions.
2. Directory index Setup error (index directive configuration)
The web site root does not contain a file that is set by the index directive.
For example, a Web site that runs PHP usually configures the index like this
Index index.html index.htm index.php;
When you visit the Web site, Nginx looks for files in the root directory in index.html,index.htm, index.php order. If none of the three files exists, then Nginx will return to 403 forbidden.
If index.php is not defined in index, NGINX returns directly to 403 forbidden without checking to see if the index.php exists.
Also, if you run the JSP, Py needs to add index.jsp,index.py to the Directory index instruction index.
Solution: Add the first file to the index directive, common is index.php,index.jsp,index.jsp or custom first page file.