Score:0

Magento 2 running on Ubuntu 20.04 with Nginx returns Bad Gateway Error code 502

de flag
Abe

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.