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

The method to solve the error report of 403 forbidden in Nginx

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces "the method of solving the 403 forbidden error report in Nginx". In the daily operation, I believe that many people have doubts in solving the problem of 403 forbidden error report in Nginx. The editor consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "solving the problem of 403 forbidden error report in Nginx". Next, please follow the editor to study!

I installed nginx through yum in a local virtual machine. Everything is fine, but visit Times 403.

So look at the nginx log, the path is / var/log/nginx/error.log. Open the log and find the error Permission denied. The error report is as follows:

1. Open () "/ data/www/1.txt" failed (13: Permission denied), client: 192.168.1.194, server: www.web1.com, request: "GET / 1.txt HTTP/1.1", host: "www.web1.com"

No access? Therefore, we have found a lot of information, and we can solve this problem through the following four steps. You may just have a problem with the previous configuration, not necessarily using all four steps.

1. Due to the inconsistency between the startup user and the nginx working user

1.1 looking at the startup user of nginx, it is found that it is nobody, but started with root.

Command: ps aux | grep "nginx: worker process" | awk' {print $1}'

1.2 change the user of nginx.config to be the same as the startup user

Command: vi conf/nginx.conf

Second, the missing index.html or index.php file is the file specified in the line index index.html index.htm in the configuration file.

1. Server {2. Listen 80 politics 3. Server_name localhost;4. Index index.php index.html;5. Root / data/www/;6.}

If there is no index.php,index.html under / data/www/, the direct file will report 403 forbidden.

Third, permission problem. If nginx does not have the permission to operate the web directory, there will be a 403 error.

Solution: modify the read and write permissions of the web directory, or change the startup user of nginx to the user of the directory, and restart Nginx.

1. Chmod-R 777 / data2. Chmod-R 777 / data/www/

Fourth, the reason why SELinux is set to on (enabled).

Check the status of the current selinux.

1. / usr/sbin/sestatus

4.2.Modification SELINUX=enforcing to SELINUX=disabled state.

1. Vi / etc/selinux/config2.3. # SELINUX=enforcing4. SELINUX=disabled

4.3. Restart takes effect. Reboot .

1. Reboot at this point, the study on "solving the problem of 403 forbidden errors in Nginx" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Internet Technology

Wechat

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

12
Report