请求行太大 - 枪支

发布于 2025-01-26 11:56:26 字数 881 浏览 4 评论 0原文

我已经使用了烧瓶一年多了,我使用Gunicorn WSGI服务器将部署烧瓶应用程序用于生产。最近,我遇到了一个奇怪的错误,

<html>
  <head>
    <title>Bad Request</title>
  </head>
  <body>
    <h1><p>Bad Request</p></h1>
    Request Line is too large (4269 &gt; 4094)
  </body>
</html>

我在大多数get请求中遇到了此错误。

在调试时,我知道,我需要增加- gunicorn中的limit-request-line config在我将其增加到8190我的dockerfile < /code>,我能够成功地看到烧瓶应用程序的响应。

我所做的码头文件是

CMD gunicorn app:app  -w 2 --threads 50 -b 0.0.0.0:8080 --limit-request-line 8190 --capture-output --log-level info

我在这里的问题, 为什么HTTP请求行大小/长度突然增加,因为我没有在过去40天内重新启动烧瓶应用程序,因此Gunicorn版本没有更改。服务器完美地返回响应39天,然后突然给了我这个错误。

有什么想法吗?

edit1: 我发现问题是由于多个滤波器值而形成的大get请求。

I have been using Flask for over a year, I used deploy my Flask app into production using Gunicorn WSGI server. Recently I encountered a weird error that,

<html>
  <head>
    <title>Bad Request</title>
  </head>
  <body>
    <h1><p>Bad Request</p></h1>
    Request Line is too large (4269 > 4094)
  </body>
</html>

I encountered this error for most of my GET requests.

While debugging I came to know that, I need to increase the --limit-request-line config in Gunicorn after I increased that to 8190 in my Dockerfile, I was able to see the responses from the Flask app successfully.

The dockerfile change I made was

CMD gunicorn app:app  -w 2 --threads 50 -b 0.0.0.0:8080 --limit-request-line 8190 --capture-output --log-level info

My question here is,
Why did the http request line size/length increase suddenly, because I haven't redeployed my Flask app in past 40 days, so the Gunicorn version wasn't changed. The server was returning responses perfectly for 39 days, then suddenly it gave me this error.

Any idea on this?

Edit1:
I found that the issue was due to the large get request being formed due to multiple filter values.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

揪着可爱 2025-02-02 11:56:26

SET - limit-request-line to 0。这将允许无限的请求长度。但是,在代码中添加请求尺寸验证以避免任何安全风险。

Set --limit-request-line to 0. This will allow unlimited request length. However, add a request size validation inside code to avoid any security risks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文