A
A
Alexander Afanasiev2016-08-23 11:55:31
PHP
Alexander Afanasiev, 2016-08-23 11:55:31

How to handle "upstream timed out (110: Connection timed out)" error in nginx?

Greetings. the essence is that:
The sheaf nginx+php-fpm works.
trying to get data from our domain controller using OpenLdap

$ldap = ldap_connect($ldaphost,$ldapport) or die("Cant connect to LDAP Server");
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3); //Включаем LDAP протокол версии 3
if ($ldap)
{
            $bind = ldap_bind($ldap,$login,$password);
}

When the domain controller is available and working, there are no problems, everything is as it should be.
when the controller is not available die("Cant connect to LDAP Server"); and if ($ldap) don't help. i.e. $ldap is not false anyway. this is normal because the documentation says that "When using OpenLDAP 2.xx , ldap_connect() will always return a resource because it doesn't actually connect, it only initializes the connection parameters."
Apache, when the controller is not available, tries to reach, fails, scores and executes the code further. $bind = ldap_bind($ldap,$login,$password) stupidly returns false/
But nginx crashes on this function, writes to the logs
[error] 32059#0: *3002 upstream timed out (110: Connection timed out) while reading response header from upstream

How can I process this piece of code, at least to issue a message like "The domain controller is dead, contact the system administrator." try catch didn't help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy, 2016-09-03
@omsknews

error_page 500 502 503 504 /telToAdmin.html;
such a wonderful line does not work or does not suit?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question