Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Solutions to the 403 problems caused by nginx configuration

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

403 problems caused by nginx configuration

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

The nginx_error.log is as follows:

II. QUESTIONS

1. www.requesturi.com is configured as follows: it is found that the root directory is inconsistent with the files prohibited from accessing in the error log. In theory, visiting www.requesturi.com should go to/usr/local/nginx/html1 to find it. Why does it show that access is indeed prohibited in/usr/local/nginx/html?

2. Curl an a.txt file under/usr/local/nginx/html1 and find that the error is 404.

III. Resolution

It can be roughly inferred that www.requesturi.com is not configured in nginx.conf. Check nginx.conf found: www.requesturi.com is not configured, and nginx is the default directory that does not allow access to files, so there will be 403 errors.

Check the configured www.zhuye.com again and find that the root directory of www.zhuye.com is the same as the directory prohibited from accessing in the error log, and the server_name is an ip instead of a domain name.

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

You can modify nginx configuration so that nginx can access file directories:

Display files under directory:

Thank you for reading, hope to help everyone, thank you for your support of this site!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report