部署遇到的错误状态码

164 阅读1分钟

502 错误网关

有个bcript包没下载

image.png

500 服务器错误

把项目放在root目录有权限问题

解决方法:项目放在var目录

405 Method Not Allowed,即方法不被允许

请求url路径写错了,多写/

404

没配置nginx对option请求的处理

if ($request_method = "OPTIONS") { 
add_header 'Access-Control-Allow-Origin' "$http_origin";
add_header 'Access-Control-Allow-Credentials' "true";
add_header 'Access-Control-Max-Age' 86400; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, DELETE'; 
add_header 'Access-Control-Allow-Headers' 'reqid, nid, host, x-real-ip, x-forwarded-ip, event-type, event-id, accept, content-type'; 
add_header 'Content-Length' 0; add_header 'Content-Type' 'text/plain, charset=utf-8'; return 204; 
}

配置完成后,使用 sudo nginx -t 检查配置文件语法,若无误则使用 sudo systemctl restart nginx 重启 Nginx 服务使配置生效。