I need some help to understand why a PHP-FPM chrooted PHP script fails to resolve an FQDN few instants after the PHP-FPM service started.
When I (re)start the PHP-FPM service, it works (resolution succeeds) a few seconds and then resolution fails.
I chrooted a PHP application (a WordPress actually) via PHP-FPM (settings `` chroot` in the PHP-FPM pool configuration file) and gave PHP what it needed:
<ul>
<li>A basic
file</li>
<li>A
of /etc/ssl/certs</li>
<li>A
(via
)</li>
<li>A
of /usr/share/zoneinfo</li>
<li>A
of /var/run/mysqld for the socket to MySQL.</li>
<li>A
of /var/run/nscd for the socket to nscd resolver.</li>
<li>A place to store PHP sessions</li>
</ul>
I noticed the issue when WordPress complained it could not download updates with:
<em>stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known stream_socket_client(): unable to connect to tcp://www.wordpress.org:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known)</em>
Sample script:
When it works:
After a few instants:
Note that, in any case, both
and
<strong>always</strong> works fine.
Three questions:
<ol>
<li>What makes
and
achieve to resolve FQDN when
fails?</li>
<li>What does
need in a chrooted setup?</li>
<li>What could make it works only for a few moment?</li>
</ol>
Software versions:
<ul>
<li>Debian 9</li>
<li>Nginx 10.3</li>
<li>PHP 7.0.19</li>
</ul>
Thanks
When I (re)start the PHP-FPM service, it works (resolution succeeds) a few seconds and then resolution fails.
I chrooted a PHP application (a WordPress actually) via PHP-FPM (settings `` chroot` in the PHP-FPM pool configuration file) and gave PHP what it needed:
<ul>
<li>A basic
Code:
/etc/hosts
<li>A
Code:
mount --bind
<li>A
Code:
/dev/urandom
Code:
mknod
<li>A
Code:
mount --bind
<li>A
Code:
mount --bind
<li>A
Code:
mount --bind
<li>A place to store PHP sessions</li>
</ul>
I noticed the issue when WordPress complained it could not download updates with:
<em>stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known stream_socket_client(): unable to connect to tcp://www.wordpress.org:80 (php_network_getaddresses: getaddrinfo failed: Name or service not known)</em>
Sample script:
Code:
<?php
$domain = 'www.example.com';
echo 'gethostbynamel(): '; var_dump(gethostbynamel($domain));
echo 'checkdnsrr(): '; var_dump(checkdnsrr($domain, 'A'));
echo 'dns_get_record(): '; var_dump(dns_get_record($domain));
?>
When it works:
Code:
gethostbynamel(): array(1) {
[0]=>
string(13) "93.184.216.34"
}
checkdnsrr(): bool(true)
dns_get_record(): array(1) {
[0]=>
array(5) {
["host"]=>
string(15) "www.example.com"
["class"]=>
string(2) "IN"
["ttl"]=>
int(86348)
["type"]=>
string(1) "A"
["ip"]=>
string(13) "93.184.216.34"
}
}
After a few instants:
Code:
gethostbynamel(): bool(false)
checkdnsrr(): bool(true)
dns_get_record(): array(1) {
[0]=>
array(5) {
["host"]=>
string(15) "www.example.com"
["class"]=>
string(2) "IN"
["ttl"]=>
int(86400)
["type"]=>
string(1) "A"
["ip"]=>
string(13) "93.184.216.34"
}
}
Note that, in any case, both
Code:
dns_get_record()
Code:
checkdnsrr()
Three questions:
<ol>
<li>What makes
Code:
dns_get_record()
Code:
checkdnsrr()
Code:
gethostbynamel()
<li>What does
Code:
gethostbynamel()
<li>What could make it works only for a few moment?</li>
</ol>
Software versions:
<ul>
<li>Debian 9</li>
<li>Nginx 10.3</li>
<li>PHP 7.0.19</li>
</ul>
Thanks