• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Issue Change Root in ngnix directives

Lrnt

Basic Pleskian
I am running Plesk Onyx Version 17.8.11 on Debian 9.8‬.
I want to specify a custom root location for a subdomain.
This works well in Apache but not in nginx.

"root /var/www/vhosts/{mydomain}/httpdocs;" under nginx directives on the subdomain ({mysubdomain}) configuration give the error "ginx: [emerg] "root" directive is duplicate in /var/www/vhosts/system/{mysubdomain}/conf/vhost_nginx.conf:2 nginx: configuration file /etc/nginx/nginx.conf test failed

Has someone a solution for this?
Thanks :)

Temporary fix: disable nginx. but that's not a solution
 
Last edited:
When you go to Hosting Settings of your subdomain you can change the Document root there. Or it's not enough?
 
Thank you @IgorG but unfortunately no, it's not enough! Here why:

  • I host a website on mywonderful.site
    Note: this is not a real domain, just a subscription, not directly accessible over the internet without a domain
  • I set up several domains which need to access mywonderful.site
  • Then I use the domain name to init database, data, theme etc.

So as you can understand, the document root is in another subscription than the domain so not accessible in hosting settings.

Here is my Apache directive to do this without nginx, maybe it will help to understand:

Code:
DocumentRoot "/var/www/vhosts/mywonderful.site/httpdocs"
<Directory /var/www/vhosts/mywonderful.site/httpdocs>
    <IfModule mod_proxy_fcgi.c>
        <Files ~ (\.php$)>
            SetHandler proxy:unix:///var/www/vhosts/system/mywonderful.site/php-fpm.sock|fcgi://127.0.0.1:9000
        </Files>
    </IfModule>
</Directory>

This is working without nginx. I just want to make it working with it but I can not change document root in nginx directive: "nginx: [emerg] "root" directive is duplicate..."
 
@Lmt,

this part

  • I host a website on mywonderful.site
    Note: this is not a real domain, just a subscription, not directly accessible over the internet without a domain
  • I set up several domains which need to access mywonderful.site
  • Then I use the domain name to init database, data, theme etc.
So as you can understand, the document root is in another subscription than the domain so not accessible in hosting settings.

of your response is simply indicating that you want to

- use other domains to proxy your mywonderful.site domain,
- use or run an application on the mywonderful.site domain,

and, in summary, you only need to

a) use Nginx as proxy, in the sense of domain x, domain y, domain z etc. proxying to the mywonderful.site domain,

b) configure Nginx properly - this is a bit difficult, since you will probably need custom Nginx config templates.

You surely do not need Apache and/or Apache config.

Nevertheless, the thing I do not understand : why do you not use domain aliases?

In essence, a domain setup as a domain alias would solve your problem without any modification : traffic to the domain alias would simply be redirected properly to your one domain called mywonderful.site - with the additional advantage that you can separately use services (like mail service) on the domain aliases.

Kind regards..........
 
Back
Top