美文网首页
sonarQube 代码检查时报错 413 Request En

sonarQube 代码检查时报错 413 Request En

作者: 惜鸟 | 来源:发表于2021-03-02 17:54 被阅读0次

错误信息

ERROR: Error during SonarQube Scanner execution
ERROR: Failed to upload report - HTTP code 413: <html>
<head><title>413 Request Entity Too Large</title></head>
<body bgcolor="white">
<center><h1>413 Request Entity Too Large
ERROR: 
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?

报错原因

用户上传数据太大,在nginx中 client_max_body_size 默认值为 1m , 该参数的作用是设置最大允许客户端请求体的大小,如果超过了此值,客户端会收到 413 状态码,意思是请求的实体太大

解决方式

我这里是将sonarQube部署到k8s上面的,并且通过nginx-ingress进行访问,我将 nginx.ingress.kubernetes.io/proxy-body-size: "20M"添加到 annotations 中:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: sonarqube
  namespace: default
  annotations:
    ingress.kubernetes.io/proxy-body-size: "20M"
spec:
  rules:
...

如果你在docker中运行sonar,默认的sonar镜像不包含nginx服务器,所以在容器中不需要做修改,因为这是nginx的问题。如果你的sonar服务是通过nginx做的转发,则需要在nginx.conf中添加如下内容:

http{
    client_max_body_size 20m;
} 

参考文章
https://www.javaroad.cn/questions/124046#

相关文章

网友评论

      本文标题:sonarQube 代码检查时报错 413 Request En

      本文链接:https://www.haomeiwen.com/subject/lqexqltx.html