On the current site example.com running Drupal 7, 2 types of errors were found in the Nginx error log:
Error caused by invalid link request: /sites/default/files/styles/news_thumb/public?itok=TDBjZ3_e
2024/09/22 01:24:54 [error] 140592#140592: *61167
upstream sent invalid "Content-Length"
header: "Content-Length: " while reading response header from upstream,
client: 47.128.116.248,
server: example.com,
request: "GET /sites/default/files/styles/news_thumb/public?itok=TDBjZ3_e HTTP/2.0",
upstream: "fastcgi://unix:/run/php/php7.4-fpm-example.com.sock:",
host: "example.com",
referrer: "https://example.com/en/news/some-new-message"
Freezes with a 500/502 offset
2024/10/23 19:16:16 [error] 1182461#1182461: *573499
connect() to unix:/run/php/php7.4-fpm-example.com.sock failed
(11: Resource temporarily unavailable) while connecting to upstream,
client: 154.213.195.169,
server: example.com,
request: "GET / HTTP/2.0",
upstream: "fastcgi://unix:/run/php/php7.4-fpm-example.com.sock:",
host: "example.com"
links that I googled:
There is not enough information in the logs to understand what exactly is causing the freezes. I tried various options to quickly solve the problems (what I googled + suggestions from ChatGPT).
Although it is generally considered that working through a socket is more reliable, an article on DigitaloOcean states:
In some cases, switching from a Unix socket to a TCP/IP socket for PHP-FPM can help, especially if you’re running into file descriptor limits.
In the config "/etc/php/7.4/fpm/pool.d/example.com.conf" I wrote:
listen = 127.0.0.1:9003
In the config "/home/user/conf/web/example.com/nginx.conf"
fastcgi_pass 127.0.0.1:9003;
The following errors also occurred:
2024/10/27 14:45:49 [alert] 347152#347152: *42845
1024 worker_connections are not enough while connecting to upstream,
client: 156.253.168.12, server: example.com,
request: "GET / HTTP/2.0", upstream: "fastcgi://127.0.0.1:9003",
host: "example.com"
The gist of the log: "1024 worker_connections are not enough while connecting to upstream"
Increased the worker_connections parameter in the config: (Source: https://stackoverflow.com/questions/56723449/nginx-error-1024-worker-connections-are-not-enough )
# Worker config
events {
worker_connections 4096;
use epoll;
multi_accept on;
}
p.s. It is important to remember that Hestia CP rewrites the config according to the template and sets the socket again (when updating the panel or when changing any nginx configuration parameters through the panel). Therefore, it is better to make separate tpl and stpl templates for such a site.