• 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

Resolved how to point a subdomain to a wildcard on nginx

Epizefiri

Basic Pleskian
Server operating system version
Ubuntu 20.04
Plesk version and microupdate number
Obsidian 18.0.42
Hallo there,
I have a laravel installations that runs on *.myapplication.it on a multi tenant mode.

That means that based on the url that the user is calling is getting the same laravel installation but a different database.
For example, if the user goes to foo.myapplication.it he will see the data relative to the company foo, and if he goes to bar.myapplication.it he will see the data relative to bar.

This have been configured on plesk with a wildcard subdomain, and it works nice!

We've got the request from a new client to run the application in white label mode on his domain.
What we would like to achieve is to have the subdomain app.newclient.it that forwards to the same folder of *.myapplication.it

this would be pretty easy on a normal nginx installation.. I would create a conf file for the subdomain and set the root folder as i want.
But i don't know how to achieve the same result on plesk, is there any way to do it graphically? is there any way to create a custom nginx file without the risk of overwrite?

Thanks
 
Couldn't you achieve the same result with a domain alias? So that for example of you have app.myapplication.it it can also be reached on app.newclient.it?
 
Hi Kaspar,
looks like I can't create aliases to a wildcard subdomain ( please try yourself, the wildcard are not listed in the possible redirects)
 
No, you can't add an alias to an (wildcard) subdomain. However you can add the alias to the primary domain (in your example that would newclient.it would be an alias of myapplication.it). My thinking was that the alias domain would also function as an alias for the wildcard. I just tested this, but unfortunately it does not seems to work. At least not at my server. You could give it a try on your onw server and see if works for you. Another issue with this approach would SSL certificates, I am not sure how LE would handle this scenario.

So, sorry, my solution does probably not work.
 
Alternatively, you could try to add a secondary domain in Plesk to the primary subscription that uses the same document root as the wildcard domain. Like so:

Schermafbeelding 2022-07-21 192124.png
 
Hi kaspar,
yes, LE is gonna be a problem.. but I prefer to solve a problem at a time.

Thank you so much for your help, I really appreciate your commitment and patience.

I'm not 100% sure to understand this screenshot:
1658445779959.png

for my knowledge the "appdocs" folders in this screenshot are gonna be two different folders
one is gonna be /var/www/vhosts/app.newclient.it/httpdocs/appdocs
the other is gonna be /var/www/vhosts/myapplication.it/appdocs

In fact, when I try to set a document root I'm limited to the "home" of the domain
1658445960539.png

Am I missing something? I was also thinking about using a symbolic link between these two appdocs folders.. but i'm not sure that this is not gonna create any conflict
 
for my knowledge the "appdocs" folders in this screenshot are gonna be two different folders
one is gonna be /var/www/vhosts/app.newclient.it/httpdocs/appdocs
the other is gonna be /var/www/vhosts/myapplication.it/appdocs
No, if you add app.newclient.it as an secondary domain to myapplication.it both domains will share the same webspace (home directory). So is for example /var/www/vhosts/myapplication.it/[document root]. Because they share the same webspace you can configure the same Document Root for both the wildcard subdomain (*.myapplication.it) and the custom domain app.newclient.it.

I hope that makes sense? Try for yourself by adding a secondary domain to your primary domain.
 
Hi Kaspar,
that absolutely make sense, but I probably miss a step.

How do you create a secondary domain? I don't see this options (probably because I'm using a localized versione of plesk).
Could you show me a screenshot of where to click to get it?
 
How you can add a secondary domain depends on which Plesk view you're using. Plesk has two view modes, called Provider View and Power User View. The difference between these two View modes is explained here: https://support.plesk.com/hc/en-us/...-User-View-and-Service-Provider-View-in-Plesk

I am guessing you are using Power User view, but if you're using Provider View i'll list the steps bellow two.

1) On the left side menu click Website & Domains
2) Then click on the blue button "Add domain"
Schermafbeelding 2022-07-22 om 14.54.24.png
3) In the next screen click to create a"Blank website"
Schermafbeelding 2022-07-22 om 14.54.33.png
4) Then on the next screen you enter "app.newclient.it" as the domain name and select myapplication.it as the webspace.
Schermafbeelding 2022-07-22 om 15.03.31.png
5) Afterwards you can change the document root of app.newclient.it to match the document root of *.myapplication.it on the Hosting Settings on the Hosting & DNS tab.

If your using provider view then follow these steps:

1) On the left side menu click Subscriptions
2) Click on myapplication.it in the subscription list
3) Then click on the blue button "Add domain"
4) In the next screen click to create a"Blank website"
5) You're done. You can now change the document root of app.newclient.it to match the document root of *.myapplication.it on the Hosting Settings on the Hosting & DNS tab.
 
Back
Top