Nginx (Error) 503 Bag GateAway

Nginx Bad Gate-Away Error

        When you work with Nginx Server as a Web Server or a Reverse Proxy Server, sometimes you might experience a "Bad Gateway" Error where Ingenx fails to load the Application. The solution to solving this problem in Ubuntu is by going to var/logs/nginx folder and then get the error.log file, bring it to the local machine to examine it. Most of the time the error looks like this:

2019/02/26 16:16:45 [error] 12544#12544: *5608 upstream sent too big header while reading response header from


        Specifically working with Drupal 8, Nginx and PHP7.2-fpm, it is advisable to check the error logs in the var/logs folder if you are working with Ubuntu Linux (18.0.4). When you check the logs, you will find the Nginx logs folder and find a current log, copy the error into Google Search and find how other developers resolved the issue. 

Solution:

In my case the error was:
2019/01/03 15:56:15 [error] 3694#3694: *36 upstream sent too big header while reading
response header from upstream, client: 98.987.8776, server: ,
request: "GET /dormainName HTTP/1.1",
upstream: "fastcgi://unix:/var/run/php/php7.2-fpm.sock:",
host: "176.098.87:81"

Solution:

 Navigate to the sites-available folder in etc/nginx and find sites-available folder then modify whatever file name you have that defines the sites-enabled. Under location ~ '\.php$|^/update.php' {} block, include the code below for FastCGI to return/accept large buffer.

    fastcgi_max_temp_file_size 0;
    fastcgi_buffers 128 2048k;
    fastcgi_buffer_size 2048k;

    fastcgi_read_timeout 600;
    fastcgi_send_timeout 600;