用nginx重建了maven仓库后,jenkins的包一直上传失败,返回413

为了把测试环境中所有的虚机换成物理机,今天把最后一个东东Maven仓库迁移到物理机就算全完工了。结果,出岔子了。

事情是这样的,为了清爽,我为每一个web服务弄了一个域名:
jenkins.allure.so
maven.allure.so
gitlab.allure.so
svn.allure.so...

为了方便,我用nginx做了端口映射。弄完后,美美地搭建了一个基于Nexus的Maven仓库,并把所有pom文件中的仓库地址指向maven.allure.so。
一开始很顺利,用jenkins编译完之后,jenkins会自动把生成的包存一份到maven仓库中。

在编译最基础的包,cu-common的时候,终于遇到妖魔事件,jenkins在把包传到maven的时候报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project cu-common: Failed to deploy artifacts: Could not transfer artifact cu:cu-common:jar:master from/to releases (http://maven.allure.so/nexus/content/repositories/releases): Failed to transfer file: http://maven.allure.so/nexus/content/repositories/releases/cu/cu-common/master/cu-common-master.jar. Return code is: 413, ReasonPhrase: Request Entity Too Large. -> [Help 1]

我当时以为是比较简单的配置问题,可能Nexus哪个地方需要配置一下文件大小限制,于是慢google和baidu找遇到相同问题的人,结果。。。没有遇到相同问题的人!偶尔有也没有明确的答案。因为Nexus的HTTP实现是构建于Jetty之上的,我还自作聪明修改了jetty的http参数,结果问题依旧。

说来惭愧,下午搞了将近七个小时都没有搞定,崩溃边缘,11点半坐在家里郁闷的时候,突然想起来,可能是Nginx搞的鬼:
因为Nginx做了maven.allure.so的端口分发,所有的流量都会流经Nnginx后到达Nexus,而在Nginx层面,http的包大小默认做了限制。

在Nginx的http配置中增加一条配置后问题解决:
http {
    #......
    client_max_body_size 300M;
    #......
}

碎觉。

猜你喜欢

转载自fredlong.iteye.com/blog/2215235