I have a fresh install of Magento 2.4.4-p2 on Ubuntu 20.04. The PHP version is 8.1.13 and the nginx version is 1.18.0 (Ubuntu). I can see and access the home page and the following pages without 502 bad gateway error:
https://example.com/sales/guest/form/
https://example.com/catalogsearch/advanced/
Everything else including the admin page and any activity on the above pages such as a search query returns bad gateway error 502. Inside /etc/nginx/sites-available
I have example.com
virtual host with the following configuration:
upstream fastcgi_backend {
server unix:/run/php/php8.1-fpm.sock;
}
server {
listen 80;
server_name example.com;
set $MAGE_ROOT /var/www/example.com/html;
include /var/www/example.com/html/nginx.conf.sample;
client_max_body_size 2M;
listen 443 ssl http2;
listen [::]:443 ssl http2;
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/key.pem;
access_log /var/log/nginx/magento.access;
error_log /var/log/nginx/magento.error;
}
I followed the documentation and adjusted the below in /etc/php/8.1/fpm/php.ini
:
memory_limit = 2G
max_execution_time = 1800
zlib.output_compression = On
Usually, this issue is caused by an incorrect Nginx configuration file. But this is what Magento 2 documentation stated. How can I fix this? - The error log is clean.
The content of include /var/www/example.com/html/nginx.conf.sample;
is here.