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

Nginx report 403 forbidden error how to solve

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of how to solve Nginx 403 forbidden errors, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this Nginx 403 forbidden error resolution article. Let's take a look.

There are usually three situations that cause nginx 403 forbidden: the first is the lack of index file, the second is permission problem, and the third is selinux status.

1. Missing index.html or index.php file, which is the file specified in the line index index.html index.htm in the configuration file

Server {listen 80; server_name localhost; index index.php index.html; root / var/www;}

If you visit the domain name directly and cannot find the file when there is no index.php,index.html under / var/www, you will report 403 forbidden.

Second, 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.

Chmod-r 755 / var/www

3. The reason why selinux is set to enabled

First, check the enabled status of native selinux. If the parameter selinux status is enabled, it will be enabled.

/ usr/sbin/ sestatus-v

Or use the getenforce command to check

Found out the reason, how to shut down selinux

1. Temporary shutdown (no need to restart)

Setenforce 0

2. Modify the configuration file / etc/ selinux/config to change selinux=enforcing to selinux=disabled

Vi / etc/ selinux/config

Note: modifying the configuration file requires restarting the system reboot

* if none of the above methods can be solved, there is one more thing to pay attention to *

View nginx.conf:

User nobody

Change it to: user root

Stop nginx-s stop

Restart nginx-c nginx.conf

This is the end of the article on "how to solve the forbidden error in Nginx News 403". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to solve Nginx 403 forbidden errors". If you want to learn more, you are welcome to follow the industry information channel.

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