Fastcgi_buffers и fastcgi_busy_buffers_size

Hello to everyone again. I have a problem with my website. It gives a 502 error on some pages. I have such a problem not only here, but everywhere where there is nginx. I usually solved it like this: I increased fastcgi_buffers and fastcgi_busy_buffers_size. I installed hestiacp and increased these values in FastCGI settings, but the error persists. Why? If everything worked everywhere? What did I forget?

Here is the config with which everything worked on my vesta , but does not work on hestia

Operational configuration events {
working connections 1024;
use epoll;
multi_accept on;
}

http {

Basic Settings

send a file to;
tcp_nopush is enabled;
tcp_nodelay on;
client_header_timeout 1m;
client_body_timeout 1m;
client_header_buffer_size 2k;
size client_body_buffer_size 256k;
client_max_body_size 256m;
large_client_header_buffers 4 8k;
send_timeout 30;
keepalive_timeout 60 60;
reset_timedout_connection on.;
server_tokens is disabled;
server_name_in_redirect is disabled;
server_names_hash_max_size 512 server_name;
server_name, hash_backet_size 512;

Journal format

log_format main '$remote_addr - $remote_user [$time_local] $request ’
'“$status” $body_bytes_sent “$http_referer” ’
‘“$http_user_agent” “$http_x_forwarded_for”’;
bytes of log_format ‘$body_bytes_sent’;
#access_log /var/log/nginx/access.log home;
access_log is disabled;

Mime settings

enable /etc/nginx/mime.types;
default_type application/default octet stream;

Compression

gzip on;
gzip_comp_level 9;
gzip_min_length 512;
gzip_buffers 8 64k;
gzip_types text / plain text / css text / javascript text / js text / xml application / json application / javascript application / x-javascript application / xml application / xml+ rss application /x-font-ttf image /svg +xml font /opentype;
gzip_proxied any;
gzip_disable “MSIE [1-6].”;

Proxy Server Settings

the proxy server is disabled;
proxy_set_header Host $host;
proxy_set_header X-Real IP $remote_addr;
proxy_set_header X-Redirected-for $proxy_add_x_forwarded_for;
proxy_pass_header Cookie set;
proxy_connect_timeout 900;
proxy_send_timeout 900;
proxy_read_timeout 900;
proxy_buffer_size 128 kb;
proxy buffers 4 256k;
proxy_busy_buffers_size 256k;

Can anyone help? Please

you need to be more descriptive.

what setup are you running, e.g. nginx only or apache2 as well? which php version(s)?
where exactly did you change which fastcgi setting to what number?
the config you posted does not hold anything related to that…

hestia is not vesta, a lot has changed so your error probably needs proper debugging, not just copying over some old config values :wink:

what does the log file say?

Hi. Error 502 appears when I use apache + nginx, php version 7.4. Now I have re-installed the server and have not changed any settings yet. The site opens and gives a 502 error on some pages. Here are the logs with errors

[Thu Jan 12 09:55:25.761687 2023] [autoindex:error] [pid 32509:tid 140137556080384] [client 15.204.173.67:0] AH01276: Cannot serve directory /home/kirill/web/expromt.speedbooking.ru/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Thu Jan 12 09:55:31.191124 2023] [autoindex:error] [pid 32509:tid 140137400858368] [client 39.110.218.101:0] AH01276: Cannot serve directory /home/kirill/web/expromt.speedbooking.ru/public_html/: No matching DirectoryIndex (index.html,index.cgi,index.pl,index.php,index.xhtml,index.htm) found, and server-generated directory index forbidden by Options directive
[Thu Jan 12 09:57:39.010363 2023] [proxy_fcgi:error] [pid 32508:tid 140137191171840] [client 80.234.89.184:0] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function onrErrorHandler(), 4 passed and exactly 5 expected in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/error.php:3\nStack trace:\n#0 /home/kirill/web/expromt.speedbooking.ru/public_html/sys/error.php(38): onrErrorHandler()\n#1 [internal function]: onrShutdownHandler()\n#2 {main}\n thrown in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/error.php on line 3’, referer: Заказы - Парикмахерская "Экспромт"
[Thu Jan 12 09:57:39.010437 2023] [proxy_fcgi:error] [pid 32509:tid 140137384072960] [client 80.234.89.184:0] AH01071: Got error ‘PHP message: PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function onrErrorHandler(), 4 passed and exactly 5 expected in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/error.php:3\nStack trace:\n#0 /home/kirill/web/expromt.speedbooking.ru/public_html/sys/error.php(38): onrErrorHandler()\n#1 [internal function]: onrShutdownHandler()\n#2 {main}\n thrown in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/error.php on line 3’, referer: Заказы - Парикмахерская "Экспромт"
[Thu Jan 12 10:00:23.074476 2023] [proxy_fcgi:error] [pid 40091:tid 140137442821888] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:00:25.453761 2023] [proxy_fcgi:error] [pid 40091:tid 140137572865792] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: Контактная информация - Парикмахерская "Экспромт" Записывайтесь - быстрее
[Thu Jan 12 10:00:27.202192 2023] [proxy_fcgi:error] [pid 40092:tid 140137581258496] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:00:34.902918 2023] [proxy_fcgi:error] [pid 40092:tid 140137308604160] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
2023/01/12 10:00:49 [error] 40212#40212: *148 upstream sent too big header while reading response header from upstream, client: 80.234.76.51, server: expromt.speedbooking.ru, request: “POST /sys/ HTTP/2.0”, upstream: “https://46.175.147.153:8443/sys/”, host: “expromt.speedbooking.ru”, referrer: “https://expromt.speedbooking.ru/
[Thu Jan 12 10:01:04.922485 2023] [proxy_fcgi:error] [pid 40091:tid 140137342109440] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:01:35.647483 2023] [proxy_fcgi:error] [pid 40091:tid 140137325324032] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:02:05.442663 2023] [proxy_fcgi:error] [pid 40092:tid 140137564473088] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:02:35.446965 2023] [proxy_fcgi:error] [pid 40092:tid 140137581258496] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:02:45.467184 2023] [proxy_fcgi:error] [pid 40091:tid 140137581258496] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
2023/01/12 10:02:51 [error] 40212#40212: *197 upstream sent too big header while reading response header from upstream, client: 80.234.76.51, server: expromt.speedbooking.ru, request: “POST /sys/ HTTP/2.0”, upstream: “https://46.175.147.153:8443/sys/”, host: “expromt.speedbooking.ru”, referrer: “https://expromt.speedbooking.ru/
[Thu Jan 12 10:03:08.905887 2023] [proxy_fcgi:error] [pid 40091:tid 140137325324032] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
2023/01/12 10:03:31 [error] 40212#40212: *197 upstream sent too big header while reading response header from upstream, client: 80.234.76.51, server: expromt.speedbooking.ru, request: “POST /sys/ HTTP/2.0”, upstream: “https://46.175.147.153:8443/sys/”, host: “expromt.speedbooking.ru”, referrer: “https://expromt.speedbooking.ru/
[Thu Jan 12 10:04:57.444117 2023] [proxy_fcgi:error] [pid 40091:tid 140137556080384] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:05:21.030997 2023] [proxy_fcgi:error] [pid 40092:tid 140136595584768] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:05:23.327337 2023] [proxy_fcgi:error] [pid 40092:tid 140137572865792] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: Контактная информация - Парикмахерская "Экспромт" Записывайтесь - быстрее
[Thu Jan 12 10:05:24.899331 2023] [proxy_fcgi:error] [pid 40092:tid 140137547687680] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: Новости - Парикмахерская "Экспромт" Записывайтесь - быстрее
[Thu Jan 12 10:05:26.575868 2023] [proxy_fcgi:error] [pid 40092:tid 140137468000000] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: Вакансии - Парикмахерская "Экспромт" Записывайтесь - быстрее
[Thu Jan 12 10:05:31.261419 2023] [proxy_fcgi:error] [pid 40091:tid 140137325324032] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
[Thu Jan 12 10:05:40.040209 2023] [proxy_fcgi:error] [pid 40092:tid 140137459607296] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
2023/01/12 10:05:46 [error] 40212#40212: *197 upstream sent too big header while reading response header from upstream, client: 80.234.76.51, server: expromt.speedbooking.ru, request: “POST /sys/ HTTP/2.0”, upstream: “https://46.175.147.153:8443/sys/”, host: “expromt.speedbooking.ru”, referrer: “https://expromt.speedbooking.ru/
[Thu Jan 12 10:08:41.222502 2023] [proxy_fcgi:error] [pid 48922:tid 139771917625088] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/
2023/01/12 10:08:52 [error] 49805#49805: *334 upstream sent too big header while reading response header from upstream, client: 80.234.76.51, server: expromt.speedbooking.ru, request: “POST /sys/ HTTP/2.0”, upstream: “https://46.175.147.153:8443/sys/”, host: “expromt.speedbooking.ru”, referrer: “https://expromt.speedbooking.ru/
[Thu Jan 12 10:09:11.259327 2023] [proxy_fcgi:error] [pid 48921:tid 139771875661568] [client 80.234.76.51:0] AH01071: Got error ‘PHP message: PHP Notice: Undefined variable: onr_return_time in /home/kirill/web/expromt.speedbooking.ru/public_html/sys/time.php on line 18’, referer: https://expromt.speedbooking.ru/

Everything works on the nginx assembly only. Everything works on the apache build only. But not here… What could be the matter?)

Google this error and you see what to change

2 Likes

if you run apache2+php, apache2 takes care of buffering between the two (if any). this seems to be working.

if you run nginx+php, nginx takes care of buffering between the two via fastcgi_buffers. this seems to be working (at least after you adjusted those)

if you run nginx+apache2+php, nginx takes care of buffering between nginx and apache2 via proxy_buffers. this seems to be to small for whatever your page/app does, hence you need to adjust those. (not fastcgi_buffers, because nginx does not talk to php directly in this case)

2 Likes

Friends, thank you! I Googled this error and found a solution - I increased and added some parameters to the config that you suggested here.
A little later I will send here what I changed!

proxy_buffer_size 128k;
proxy_busy_buffers_size 256k;
proxy_buffers 4 256k;