简体   繁体   中英

plesk & nginx: different domains and subdomains should point to the same file location

i have a webapplication (on a selfhosted plesk 18.0.48 Obsidian) that should be available by 3 or even more domains. All Domains should point to the same directory. The domain names should be preserved. Currently, each domain has its own plesk subscription. SSL is a must-have.

the current behavior is:

domain1.de -> /var/www/vhost/webApp1/public;
domain2.de -> /var/www/vhost/webApp2/public;
domain3.de -> /var/www/vhost/webApp3/public;
domainX.de -> /var/www/vhost/webAppX/public;

test.domain1.de -> /var/www/vhost/webApp1/text;
test.domain2.de -> /var/www/vhost/webApp2/text;
test.domain3.de -> /var/www/vhost/webApp3/text;
test.domainx.de -> /var/www/vhost/webAppX/text;

dev.domain1.de -> /var/www/vhost/webApp1/dev;
dev.domain2.de -> /var/www/vhost/webApp2/dev;
dev.domain3.de -> /var/www/vhost/webApp3/dev;
dev.domainx.de -> /var/www/vhost/webAppX/dev;

How could I achieve the following target behavior?:

domain1.de -> /var/www/vhost/webApp/public;
domain2.de -> /var/www/vhost/webApp/public;
domain3.de -> /var/www/vhost/webApp/public;
domainX.de -> /var/www/vhost/webApp/public;

test.domain1.de -> /var/www/vhost/webAppTest/public;
test.domain2.de -> /var/www/vhost/webAppTest/public;
test.domain3.de -> /var/www/vhost/webAppTest/public;
test.domainx.de -> /var/www/vhost/webAppTest/public;

dev.domain1.de -> /var/www/vhost/webAppDev/public;
dev.domain2.de -> /var/www/vhost/webAppDev/public;
dev.domain3.de -> /var/www/vhost/webAppDev/public;
dev.domainx.de -> /var/www/vhost/webAppDev/public;

... and so one.

First, I thought of configuring an nginx reverse proxy via plesk ui I tried https://stackoverflow.com/a/69956102/7210059 but it does not work, it creates a loop (according to the protocol).

location ~ / {
   proxy_pass       http://test.domain1.de:443;

   proxy_redirect   off;

   proxy_set_header Host $host;

   proxy_set_header X-Real-IP $remote_addr;

   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

   proxy_set_header X-Forwarded-Host $server_name;
}

Second i thought of merging all domains into one subscription, so that i simply can change the root directory of each domain/subdomain.

What is the best approach?

It cannot be done if the domains are in different subscriptions, because the system user accounts and file access permissions are different for each domain. The domain running under system user A cannot access the web space running under system user B etc.

If the domains are in the same subscription, you can use the "Web Hosting Settings" page in Plesk to set them to the same document root directory to achieve your goal. However, sharing the same document root directory for different domains is also not such a great idea. For the main domain example you could instead use the "Add Alias" button to create those as aliases, but for the subdomains that won't work either, because they cannot aliases. So for subdomains you can only set the document root.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM