• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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