How to solve the 403 problem caused by nginx configuration

WBOY
Release: 2023-06-01 16:25:06
forward
2173 people have browsed it

Solution to 403 problems caused by nginx configuration

1. Problem: 403 appears when curling the local domain name configured by nginx

How to solve the 403 problem caused by nginx configuration

nginx_error.log The log is as follows:

How to solve the 403 problem caused by nginx configuration

##2. Questions

1. www The configuration of .requesturi.com is as follows: It is found that the root directory is inconsistent with the forbidden files in the error log. In theory, when accessing www.requesturi.com, you should go to /usr/local/nginx/html1 to find it. Why does it show that it is indeed /usr/local? Access to /nginx/html is prohibited?

How to solve the 403 problem caused by nginx configuration

#2. Curl an a.txt file under /usr/local/nginx/html1 and find that the error turned out to be 404.

How to solve the 403 problem caused by nginx configuration

3. Solution

It can be roughly inferred that www.requesturi.com may not be configured in nginx.conf . Check nginx.conf and find that www.requesturi.com is not configured, and nginx does not allow access to the file directory by default, so a 403 error will occur.

How to solve the 403 problem caused by nginx configuration

Then check the configured www.zhuye.com and find that the root directory of www.zhuye.com is the same as the forbidden directory in the error log. Yes, and server_name is an ip instead of a domain name

How to solve the 403 problem caused by nginx configuration

Reason: Because www.requesturi.com is not configured, when we visit www.requesturi.com, nginx will access the default (that is, www.zhuye.com), and when accessing a.txt (this file does not exist in the www.zhuye.com directory), it will report a 404 not found error.


You can modify the nginx configuration so that nginx can access the file directory:

How to solve the 403 problem caused by nginx configuration

Display files in the directory:

How to solve the 403 problem caused by nginx configuration

The above is the detailed content of How to solve the 403 problem caused by nginx configuration. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!