1

I'm migrating my Joomla! application from a NGinx (cache) + Apache (php) server to a Nginx + PHP-FPM Fast CGI one. When testing the different parts of it, I found that when the backend (administrator) threw an error (i.e. Could not write that file and so on) Nginx responded with a 502 Bad Gateway error.

I've seen this question:

Nginx 502 in Administrator

But the solution there was to fix the problem causing the error rather than solving the Bad Gateway problem.

I've been trying to locate the real problem and reached to PHP responding with this as status header:

Status "0 Could not write file"

I think that Nginx is trying to map that header to a HTTP status code and then failing.

Does anyone have any idea on how to solve this?

I've seen error_page directive

nginx.org/en/docs/http/ngx_http_core_module.html#error_page

on nginx along with fastcgi_intercept_errors

nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_intercept_errors

and with proxy_intercept_errors

nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_intercept_errors

, but as the header is wrong I think I can't handle it on Nginx (also seems to control only status codes over 300)

  • Manage to solve it adding custon header on the error.php file on the administrator template... don't know if that's the best solution. – vegetable Feb 12 '15 at 17:17
  • Please post your solution and accept it as the answer so that this question can be resolved. Thank-you. – Neil Robertson Jul 10 '16 at 2:56
1

Manage to solve it adding custon header on the error.php file on the administrator template... don't know if that's the best solution.

if ($this->error->getCode() >= 400 && $this->error->getCode() <= 500) {
    header("Status: {$this->error->getCode()}", true, $this->error->getCode());
} else {
    // Here is where MySQL Error would fit (e.g. mysql error 1064)
    header("Status: 500", true, 500);
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.