[SOLVED] how to access unix socket from within chroot jail
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a server running nginx from within a chroot jail. Nginx is able to connect to fastCGI with the following lines:
from nginx.conf:
fastcgi_pass 127.0.0.1:9000;
from php-fpm.conf:
listen = 127.0.0.1:9000
I want to use a unix socket for the connection with the following lines:
from nginx.conf:
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
from php-fpm.conf:
listen = /run/php-fpm/php-fpm.sock
Of course nginx can't find the socket from within the jail. My question is: what would be the best way to bring the socket into the jail or link to it somehow? I brought some devices into the jail with the following code:
# export JAIL=/srv/http
# mkdir $JAIL/dev
# mknod -m 0666 $JAIL/dev/null c 1 3
# mknod -m 0666 $JAIL/dev/random c 1 8
# mknod -m 0444 $JAIL/dev/urandom c 1 9
would something similar work with the unix socket?
You might look into putting the socket somewhere else, and using a bind mount to tie the "somewhere else" into the jail directory tree. I think it would work then.
I think I've copied sockets with cpio. dump/restore would definitely do it. Or just create a new one - "man perlipc" has details including code fragments that should help.
Thank you linosaurusroot and jpollard. I got it to work by simply reconfiguring php-fpm to create the socket inside the jail. I had to override a path prefix in the php-fpm.conf file. I had to do the same with mysql. My only question now is whether this is the most secure solution. If you have any insights I would be interested. If not, Thank you for your time and help so far.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.