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

Explain in detail the solution to the emergence of 403 Forbidden in Nginx

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Nginx is also a popular lightweight server, and there will be some problems in daily use. Today, when you installed and configured Nginx, you had the error of 403 Forbindden forbidden access to the Internet search, uh, the perfect solution here to share with you.

Needless to say, stick the original nginx configuration file code first.

Worker_processes 1; events {worker_connections 1024;} http {include mime.types; default_type application/octet-stream; sendfile on; autoindex on; keepalive_timeout 65; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 128k; fastcgi_buffers 4 128k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; # gzip on; gzip on Gzip_min_length 1k; gzip_buffers 4 32k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; gzip_disable "MSIE [1-6]."; server_names_hash_bucket_size 128; client_max_body_size 100m; client_header_buffer_size 256k; large_client_header_buffers 4 256k; server {listen 80 Whether server_name localhost; autoindex on; # allows access to the directory root "C:/WWW"; location / {index index.html index.htm l.php; # index.php autoindex on;} error_page 500 502 503 504 / 50x.hml; location = / 50x.html {root html } location ~\ .php (. *) ${fastcgi_pass 127.0.0.1 fastcgi_param SCRIPT_FILENAME 9000; # fastcgi_index index.php; fastcgi_split_path_info ^ ((? U). +\ .php) (/?. +) $; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info Include fastcgi_params;}} include vh_*.conf;}

You can't understand so much profile code (to make it easier to view those that have been deleted that you don't understand).

Let's start with the reasons for the emergence of 403.

When accessing this address, nginx looks for files in the root directory in the order of index.html,index.htm and index.PHP. If none of these three files exist, then nginx returns 403 Forbidden.

Learn that there are no these three files in the root directory, so directly.

Root "C:/WWW"; location / {index index.html index.htm l.php; # index.php autoindex on;}

The list of annotated projects is displayed.

Attention should be paid here.

Autoindex on;, which defaults to off, means that access to directories is prohibited and needs to be enabled.

It is also recommended that it is not easy to manage all the configuration items in this file.

Include vh_*.conf

You can introduce such a domain name and a configuration file for easy management.

The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

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