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;
        }
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM