Home > Operation and Maintenance > Nginx > How to solve the 403 problem caused by nginx configuration

How to solve the 403 problem caused by nginx configuration

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-06-01 16:25:06
forward
2428 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:
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 Issues
Error restarting nginx
From 1970-01-01 08:00:00
0
0
0
server - Nginx configuration webapp problem
From 1970-01-01 08:00:00
0
0
0
Nginx default.conf problem
From 1970-01-01 08:00:00
0
0
0
centos7 - NGINX exception occurs
From 1970-01-01 08:00:00
0
0
0
nginx load balancing
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template