Google App 引擎错误 "Upstream sent too big header"

Google App Engine error "Upstream sent too big header"

我是 运行 一个 Laravel 应用程序 Google App Engine Standard PHP 7.2,带有 Elfinder 包。

今天,我在尝试访问 Elfinder 时收到 502 错误。分析日志后,我发现了这个特殊的错误:

96 upstream sent too big header while reading response header from upstream, client: XXX.XXX.XXX.XXX, server: , request: "GET /xxx/elfinder/connector?_token=XXX", upstream: "fastcgi://unix:/tmp/google-config/php-fpm.sock:", host: "XXX", referrer: "XXX".

搜索类似问题后,我发现这可能是 nginx proxy_buffer_size 的问题。但是,我不知道如何在 Google App Engine Standard 中编辑 nginx.conf。谁能帮帮我?

提前致谢。

您在 App Engine Standard 中没有 nginx.conf 文件,因此您无法编辑或自定义它。

您在 App Engine 柔性环境中有一个 nginx.conf 文件。

Here is the Official Google Cloud Platform Documentation to create an App Engine Flexible environment, and customize the nginx.conf file.

创建 Google App Engine Flexible 环境后,如果您仍然收到 "Upstream sent too big header" 错误,这是因为 App Engine Flexible 使用默认的 proxy_buffer_size,即 4K 和你需要更多。

因此您可以将以下代码放入 nginx.conf 文件中:

location / {
    try_files $uri /index.php?q=$uri&$args;
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;
    proxy_buffer_size 128k;
    proxy_buffers 4 256k;
    proxy_busy_buffers_size 256k;

}

我在 GAE 标准 php73 上遇到了同样的问题,这个问题与 app.yaml

有关
    SESSION_DRIVER:     cookie

设置(或在您的 .env 中) 这会通过 header 发送所有 session 信息,这可能会变得太大(不知道 GAE 默认限制)

您需要为 session 使用 redis(GCS 内存存储)或数据库设置。 GCS memorystore 对我来说太贵了(每月最低 33 美元),所以我将数据库用作 session driver.