Page 1 of 1

Edit Nginx Vhost - Add path to open_basedir

Posted: Thu Dec 10, 2020 6:12 pm
by alexgarciab
Hi there, I work with VestaCP + nginx + php-fpm.

I want to be able to serve the content under "base-domain.com", when the user access to the "additional-domain.com" (on base-domain.com I have a PHP script that serves different content based on the domain from the request is coming from).

To do so, I have modified the %docroot% variable on the .stpl and .tpl vhosts files of "additional-domain.com" to the "base-domain.com" absolute path:

/home/user/web/base-domain.com/public_html/

However, when I try to access to "additional-domain.com" I get a 404 error.

Reviewing the error log, I see the following message:

Code: Select all

2020/12/10 17:42:12 [error] 1234567#1234567: *2263 FastCGI sent in stderr: "PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(/home/user/web/base-domain.com/public_html/index.php) is not within the allowed path(s): (/home/user/web/additional-domain.com/public_html:/home/user/tmp:/var/www/html:/etc/phpmyadmin:/etc/phpMyAdmin:/var/lib/phpmyadmin:/var/lib/phpMyAdmin:/etc/roundcube:/etc/roundcubemail:/var/lib/roundcube:/var/lib/roundcubemail:/tmp:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/share:/var/opt:/opt) in Unknown on line 0Unable to open primary script: /home/user/web/base-domain.com/public_html/index.php (Operation not permitted)" while reading response header from upstream, client: 123.123.123.123, server: additional-domain.com, request: "GET / HTTP/2.0", upstream: "fastcgi://unix:/run/php80-php-fpm-additional-domain.com.sock:", host: "additional-domain.com"
So apart from modifying the %docroot% path, I need to do something else, like allowing additional-domain.com to access the base-domain.com path. I guess this is done by adding a custom rule (open_basedir) to the vhosts (.stpl and .tpl) of the additional-domain.com, but I don't know how to do that.

Anyone can help? Thanks!