2

I am running a Laravel app with Google App Engine Standard PHP 7.2, with Elfinder package.

Today, I receive 502 error while trying to access Elfinder. Upon analyzing the log, I found this particular error:

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".

After googling for similar problem, I found out it is probably a problem with nginx proxy_buffer_size. However, I did not know how to edit nginx.conf in Google App Engine Standard. Can anyone help me?

Thanks in advance.

Unknown
  • 77
  • 8

2 Answers2

3

I had the same issue on GAE standard php73 and this probaby has to do with the app.yaml

    SESSION_DRIVER:     cookie

setting (or in your .env) This sends all session info via the header, and this can become too big (dont know the GAE default limit)

You will need to use a redis (GCS memorystore) or database setting for the session. GCS memorystore was too expensive ($33 per month minimum) for me so I use the database as session driver.

woens
  • 1,058
  • 9
  • 20
  • Yep. Definitely. I've found the solution but forget to post the solution here. Basically, when session is saved in cookie, the header will sent a session cookie, which is too long to be buffered by App Engine's default nginx setup. – Unknown Feb 25 '20 at 14:23
  • Thanks for this tip. I was about to change from standard to flex in App Engine, instead this simple solution worked. – Asif Apr 04 '23 at 10:19
0

You dont' have a nginx.conf file in App Engine Standard so that's why you can't edit or customize it.

You have a nginx.conf file in App Engine Flexible environment.

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

After creating a Google App Engine Flexible environment, if you still get the "Upstream sent too big header" error, it's due to that App Engine Flexible is using the default proxy_buffer_size which is 4K and you need more.

So you can put the following code in you nginx.conf file:

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;

}

Nibrass H
  • 2,403
  • 1
  • 8
  • 14
  • Thanks for your suggestion. Tried migrating to flexible env and override the proxy_buffer_size, but no luck. Problem still persist. Do you know how I can take a look at the content of upstream header response which caused the problem? I think I should start with that now. – Unknown Jan 11 '20 at 19:04