Nginx shows 500 error reasons and solutions

1. Background

Recently, an internal Nginx 500 error occurred when operating nginx. Let me record the reason here. The project adopts a front-end and back-end separation method. The back-end is SpringBoot, and the front-end is deployed under Nginx by Vue.

2. Several common errors reported by Nginx

500--服务器内部错误:服务器遇到错误,无法完成请求
501--尚未实施:服务器不具备完成请求的功能,如:当服务器无法识别请求方法时,服务器可能会返回此代码
502--网关错误:服务器作为网关或代理,从上游服务器收到了无效的响应
503--服务不可用:服务器目前无法使用,可能由于停机或者超载,通常为暂时的状态
504--网关超时:服务器作为网关或者代理,无法及时从上游服务器接收请求
505--http版本不受支持:服务器不支持请求中所使用的http协议版本

3. Solve the 500 error

  1. Insufficient resources
    Check whether the hard disk space of the server is full
    Linux system: df -h
    window system:
cmd(Dos)命令查看硬盘和内存/CPU信息等
1.查看磁盘信息:freedisk 可以查看每一个盘的剩余空间
wmic diskdrive
可以看出来牌子和大小.
Wmic logicaldisk
可以看到有几个盘,每一个盘的文件系统和剩余空间
wmic volume
每个盘的剩余空间量,其实上一个命令也可以查看的
fsutil volume diskfree c:
这个命令查看每一个卷的容量信息是很方便

2.CPU信息
wmic cpu
上面显示的有位宽,最大始终频率, 生产厂商,二级缓存等信息

3.内存信息
wmic memorychip
可以显示出来三条内存,两条256,一条1G的,速度400MHz

4.BIOS信息
wmic bios

5.电脑型号\SN\UUID等
wmic csproduct*
  1. nginx configuration file error

This does not refer to grammatical errors. If nginx has grammatical errors in the configuration file, it will prompt when it starts. When configuring rewrite, if some rules are not handled properly, a 500 error will appear. Please check your rewrite rules carefully. If some variables in the configuration file are improperly set, a 500 error will also occur, such as quoting a variable with no value. The reason
why I report an error here is:
insert image description here
this path error is caused.

  1. If there are too many concurrency, too many open files, modify the concurrency of nginx.config

The solution is:
open the /etc/security/limits.conf file and add two sentences

The copy code code is as follows:

  • soft nofile 65535
  • hard nofile 65535

Open /etc/nginx/nginx.conf
and add a line under worker_processes

The copy code code is as follows:
worker_rlimit_nofile 65535;

Restart nginx, reload settings

  1. Could be a database problem

Guess you like

Origin blog.csdn.net/u014212540/article/details/127968098