I've been experimenting with chroot'ing php-fpm pools via the built-in chroot method in php's pool config. This is for the purpose of hosting multiple wordpress websites on the same AWS EC2 instance. Its a basic LEMP stack at this point, using an AWS RDS instance for the mysql layer, and just one pool so far for one nginx vhost.
Everything is working great except for Wordpress's DB connection trying to connect to the external RDS hostname. When I tell Wordpress to use the hostname, i get mysql host not found errors in my php logs. When i ping the RDS instance for its IP (ping also works from inside the chroot), and tell Wordpress to use the IP instead, everything connects as expected (AWS Security Groups are setup correctly).
For the sake of experimentation, i've got a mount --bind
to all the system directories mounted inside the directory that the fpm pool is chroot'ed to (/etc, /lib, etc) so i know that all of the libs and dns resolvers are available to the chroot:
$ mount --bind /etc /path/to/chroot/etc
$ mount --bind /lib /path/to/chroot/lib
...
Something is up with the php mysql client not being able to resolve the hostname when browsing the site on the public web however. I've tried running the site not chroot'ed, and the connection to the RDS hostname works like it should. The site just can't reach RDS via hostname when chroot'ed.
I've been researching DNS issues that come along with chroot'ing and I just can't find anything specific to this situation. If there's any insight out there, that would be greatly appreciated.