CNAME record that points to another domain hosted on same Virtualmin Server

Hey!

So here’s where I’m stuck. I have following configuration:

Server IP: 1.1.1.1
domain#1: foo.com
domain#2: abc.com

The domain foo.com works like a charm. I’ve created a sub-server for this domain

phpmya.foo.com

Where I want to host my single PHPMyAdmin instance (don’t want multiple script installer instances).

So on domain abc.com I am adding following CNAME:

phpmya.abc.com IN CNAME phpmya.foo.com

Testing out the CNAME I’ve noticed that:

$ host -t CNAME phpmya.abc.pl
phpmya.abc.pl is an alias for phpmya.foo.com.abc.com.

I’ve decided to add the dot at the end of CNAME value so it would return phpmya.foo.com. in a fashion of NS records:

phpmya.abc.com IN CNAME phpmya.foo.com.

And now when I test out the CNAME record - it still points at the old value:

$ host -t CNAME phpmya.abc.pl
phpmya.abc.pl is an alias for phpmya.foo.com.abc.com.

For the time being I’m using Apache2 redirection (same way like admin.${DOM} works) but I would like to utilise CNAME record. Any ideas what I’m doing wrong?

Why CNAME? Why not a simple website redirect?

Ummm just exploring options.
Ws thinking if I add BIND records for new domains (in Server Templates > DNS domain) it will be automatically created and since I already have a sub-server phpmya.foo.com

Honestly I don’t see any advantage nor disadvantage over Apache Redirect. Just wondering why CNAME doesn’t work. Would like to make it work but I’ll be ok with Apache Redirect though…

You sure you did this right.

don’t you want to test phpmya.abc.com not phpmya.abc.pl

Steve

I did not anonimize/obfuscate it enough.

Of course it should be:

$ host -t CNAME phpmya.abc.com
phpmya.abc.com is an alias for phpmya.foo.com.abc.com.

I apologize for the inconvenience.

You only get the extra at the end if you leave off the dot. Feels like typo in the dns config. Maybe reload the dns.

So CNAME value should have the dot (absolute address) or not?

Cause if not then phpmya.abc.com would become phpmya.foo.com.abc.com which is kind of rubbish as I don’t have such server.

Yeah you need a dot else it adds the domain onto it, in the “value” area.

There’s also one more thing. I’ve deleted the CNAME record. Waited out 24h and added CNAME record again with absolute value.

# abc.com zone:
phpmya.abc.com.	IN	CNAME	phpmya.foo.com.

And now it kind of works but… My server (Apache) is serving the contents of /home/foo.com/public_html instead of /home/foo.com/domains/phpmya.foo.com/public_html

Sooo… Kiiiiiiind of works. But not.

That should be phpmya.abc.com IN CNAME phpmya.foo.com.

Not dot on first section.

When you create it it shouldn’t allow the dot in the first section.

Ok, ignore, in the manual edit the dot is there.

Yup:

ignore the mistypo please (phpmy.foo instead of phpmya)

Where did you find the Name Alias Records? I can’t see that in my system.

Webmin > Servers > Bind > abc.com

Perhaps different versions?

$ webmin --version
2.105

Ok, I always use virtualmin, like what it warns about at top. You may need to Apply Config (at top right) editing in webmin.

Done that (after removing existing record) via Virtualmin - the result is the same. I mean the very exact same value in the DNS zone:

# abc.com zone:
phpmya.abc.com.	IN	CNAME	phpmya.foo.com.
1 Like

This is what you want?

Well… Yeah :smiley:

But… When I open this address (phpmya.abc.com) I should get the contents of of my sub-server: /home/foo.com/domains/phpmya.foo.com/public_html, right?

But I don’t.
When I open phpmya.abc.com the address in the browser remains the same (and that’s ok) but the contents of the website are from /home/foo.com/public_html. Which is the parent domain hosted on my server. That is why I created sub-server to separate PHPMyAdmin installation from my “main” domain.

Cname just follows the IP of phpmya.foo.com, its just like adding the same A record for phpmya.abc.com that the same as phpmya.foo.com. Its basically a time saver changing alot of A records.

Apache handle all your web redirection like what you have for webmail.domain.com.
Check the Edit Directive in Config Website. I think what what you need to do.
There is Website Redirects in the gui as well.

I Still think this is the most painless solution. :ambulance:

I guess… Was thinking of something else but without Apache Rewrite it seems like that’s the case.