随笔 - 1357  文章 - 0  评论 - 1104  阅读 - 1941万

org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer. Increase maxHttpHeaderSize

springcloud项目,请求某个服务时报错如下:
org.apache.coyote.http11.HeadersTooLargeException: An attempt was made to write more data to the response headers than there was room available in the buffer. Increase maxHttpHeaderSize on the connector or write less data into the response headers

原因是请求头或者响应头数据太大导致,添加配置文件:

server.max-http-header-size=65546

 

注意不要使用server.tomcat.max-http-header-size。亲测有效。

解决:502 bad gateway

502 bad gateway——代理缓冲区设置过小
如果你使用的是nginx反向代理,如果header过大,超出了默认的1k,就会引发上述的upstream sent too big header (说白了就是nginx把外部请求给后端处理,后端返回的header太大,nginx处理不过来就会导致502。

复制代码
server {
    listen 443;
    server_name www.api.*.com api.*.com;
    ssl on;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_certificate /etc/nginx/conf.d/4952120.com.pem;
    ssl_certificate_key /etc/nginx/conf.d/4952120.com.key;

        location / {
                proxy_pass      http://apisite;
                proxy_redirect  off;
                proxy_send_timeout 300;
                proxy_read_timeout 300;
                proxy_connect_timeout 300;

                ##添加这3行
                proxy_buffer_size 64k;
                proxy_buffers   32 32k;
                proxy_busy_buffers_size 128k;
                ##添加这3行
                
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
}
复制代码

 

posted on   Ruthless  阅读(3736)  评论(0编辑  收藏  举报
编辑推荐:
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
· AI 智能体引爆开源社区「GitHub 热点速览」
历史上的今天:
2019-01-12 为什么要打板(追涨停)
2019-01-12 竞价打板的关键点
2019-01-12 何为打板
2017-01-12 svn合并分支到主干
2017-01-12 Spring Data Redis实现消息队列——发布/订阅模式
2015-01-12 列表转换成字典数据结构
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示