Having a virtual server accept both primary domain and subdomain to the same document root?

11 posts / 0 new
Last post
#1 Fri, 10/09/2015 - 14:37
MostHated

Having a virtual server accept both primary domain and subdomain to the same document root?

Hello all, Here is what I am trying to do. We have a site already up and running on another server that is in production hosted elsewhere. We will just called it domain.com. We are working on developing another site which will replace that one in house, and will be hosted in house once complete. Right now DNS for that server is pointed where it needs to go to the external production server. On my in house Virtualmin server, I created a new virtual server also named domain.com, so once we go live, I can just point DNS to the new IP, and it should take over.

What I am wanting to do though for the time being, so people externally can get to the development environment internally is, I want to have it be domain.com, but also have dev.domain.com. In external DNS for domain.com I added dev as an A name, and pointed that IP to my Virtualmin servers IP which is working properly, I get the Apache page. What I need though is when you go to dev.domain.com, instead of point to the server itself which it currently is (because of showing the apache page), I want it to point to the public_html directory of the local domain.com that is created there, so technically they will both go to the same place once DNS externally is pointed to the server here.

Basically I want dev.domain.com to simply be a subdomain that is accepted by Virtualmin but instead of being its own sub-server inside a different folder under domain.com, I want it to just go right to the public_html of domain.com.

How can I go about doing this? Do I create a new subserver first with dev.domain.com and then edit the home directory to instead of being /home/domain/domains/dev.domain.com, to being /home/domain, or is there another way to go about this? I do not need any features at all (awstats, mail, etc) I simply want dev.domain.com to point to the files within domain.com.

Thanks all!

Fri, 10/09/2015 - 15:14
andreychek

Howdy,

I want to have it be domain.com, but also have dev.domain.com. In external DNS for domain.com I added dev as an A name, and pointed that IP to my Virtualmin servers IP which is working properly, I get the Apache page.

What I would suggest, is delete any existing reference to dev.domain.com in your in-house Virtualmin server -- and then go into Create Virtual Server, and create a new Alias of domain.com.

Name that alias "dev.domain.com".

Now, you will have the new dev domain pointing right at domain.com, and both will share the same public_html folder.

-Eric

Fri, 10/09/2015 - 15:37 (Reply to #2)
MostHated

Perfect, that worked just hope I needed, thank you very much!

Sun, 10/07/2018 - 08:45 (Reply to #3)
Tortoise

I want to use a different certificate for the subdomain (e.g. some certificate authority provides the certificate for this subdomain) and or the other domain and subdomains I wan't to use the automatic Let's encrypt certificates. I guess this is not possible with an Alias isn't it?

I did create a subserver and made the docroot match that of the (root) virtual server. Would this be good practice and will it work when generating a CSR for the sub.differentdomain.tld subserver that has the same docroot?

Sun, 10/07/2018 - 10:08
Jfro

Don't know

But why not using for the "sub" a own/separate virtual server itself?

Sun, 10/07/2018 - 11:29 (Reply to #5)
Tortoise

That would be perfectly fine, however the document root should match (not be under domains) as it should serve exactly the same application, the only difference would be the certificate that is used for the domain. I think I can only use a subserver when I manually change it's document root (that would be fine but I am not sure if the automatic certificate or other stuff may interfere/overwrite the certificate for the new sub server). Would you advice to use a sub server and point it to the same document root /home/project/public ?

Mon, 10/08/2018 - 03:59
Jfro

Hmm don't know but redirects with new version virtualmin should be possible to have the lets encrypt still working Redirects for / created using the UI are automatically adjusted to exclude Let's Encrypt validation paths.

maybe helps ? ;) https://www.virtualmin.com/node/59040#new

Mon, 10/08/2018 - 06:29 (Reply to #7)
Tortoise

I suggested a redirect but it's a different organization that uses the same application and should be served a different certificate (that will match their organization). If I make it a redirect, users will see the other domain and certificate and it defeauts the purpose to use their certificate.

Mon, 10/08/2018 - 06:41
Jfro

Then simple they have to reprogram the aplication user part / frontend to have another "template" so for example the view is different i suppose. A multiple organisation aplication sorry my english... ;)

( kind of using same backend / database and so on)

Mon, 10/08/2018 - 12:59
adamjedgar

Good timing this should come up....i had an alias subdomain fail a letsencrypt certificate test just yesterday.

I just figured it was because lets encrypt cant do it and so i removed the alias virtual server instead.

AJECreative is the home of $5 webhosting, $15/month VPS servers (1cpu,1gb RAM, 25GB storage)
Centos7, Debian9, or Ubuntu18LTS
Available Control Panels = Centos-Webpanel, Cyberpanel, or Virtualmin

https://ajecreative.com.au

Mon, 10/08/2018 - 15:38
Jfro

Here something like that to , before a while ago the certs has no problems, after a while renewing then this happened.

The last one for a few days: I had to put that in the external dns to,not understanding why after about 10 months going right ( so renewed automatic several times without errors) this hapened now for the hostname. (For sure there i didn't change myself as admin any rights/ paths and domain/virtual server settings for the server, and i am the only one with rights to do so, ok the software itself and updates have ofcourse "more rights" then me ;) !)

The hostname is here: vp.hostdomain.tld The allias it ever worked ok, but now failed was webmin.vp.hostdomain.tld. This was not in the external DNS and never was. I put (webmin.vp.hostdomain.tld.) it in external dns and automatice the problem resolved after resolving the webmin.vp.hostdomain.tld. dns/ns.

So yes i was deleting the no important alias subs ( in the letsencrypt virtualmin gui) manually for the domains not important, and adding the important ones in the external dns, autoconfig, autodiscover and so on all these giving problems after running the vps for more then a half year without LE problems for those. WHY?

But Ok sorry is maybe oftopic, for reading and searching maybe still good to have that text here.

SO FOR LE not working you can see in logs wich domains/ sub/alias: check them in dns resolving and paths and rights also redirects and so on. s

Still for the question above, you have to seperate while different Organisation as he said the "subdomain" with its own separate virtual server. While you can expect problems not having them separated for a lot of data .... things. ;) ( for example EU privacy rules for website visitors)

Topic locked