Is site2.com resolving to site1.co.uk because it’s the first virtualhost on the server and basically the DNS is wrong or are both site1.com and site2.com doing this and I have not set-up server aliases correctly?
Where in the shell can I find virtualmins server alias configurations? When I look at sites-enabled it only lists the main servers ( with no mention of server aliases in their config ) on either of my two sites?
This matches the IP address showing in the virtualhost blocks (/etc/apache2/sites-enabled/) for both site1.co.uk & site2.co.uk
Please note that in these blocks I can see no immediate reference to site1.com or site2.com as server aliases - I assumed these are ‘pulled’ in from somewhere else?
Network Settings:
Network interface for virtual addresses - set to primary server (eth1)
Default virtual server IP address - set to default “From Network Interface”
Default IP address for DNS records - set to “Same as virtual server IP”. I’m not sure if behind a NAT router or not - should I assume not?
Please note that in these blocks I can see no immediate reference to site1.com or site2.com as server aliases - I assumed these are ‘pulled’ in from somewhere else?
Hmm, if you go into System Settings -> Server Templates -> Default -> Apache Website, what is “Create alias websites by” set to?
System Settings -> Server Templates -> Default -> Apache Website
“Create alias websites by” is set to “Adding ServerAlias to parent”
I have attached the code block for site2.co.uk for reference.
Please Note no .com in there although virtualmin reports it as I would expect.
Just as an aside (and possibly a noobie question):
If both server aliases were not set up properly, would they just resolve to the primary IP Address? - Which when I enter into the address bar - it resolves to site1.co.uk (possibly as this is the first virtualhost code block)?
Having continued to try and resolve this over the weekend I can confirm that my server aliases are pointing to the “default domain” and not their respective ‘parent’ servers.
The issue turned out to be a simple misinterpretation of a feature.
In creating the server alias I was unchecking Set up website for domain?
This was based on my interpretation of the help file which is written as follows:
Set up website for domain?
The module can create any or all of the following services for a new domain: mail, name service, web service. If this option is set to Yes, a new VirtualHost configuration section will be added to the Apache configuration and a new website home directory will be created.
My rationale was,
I don’t need a new website or home directory - it will resolve to an existing one
I dont need a new configuration section - I need to amend an existing one.
Thanks again for input and hope that clarifies things for someone else.
Thanks for taking the time to outline this in detail, it helps other users that could be having the same problem. Far too many people just solve something and then leave without a word. You are one of the good guys!
This was my exact issue as well. My server alias for my second site was redirecting to the default website, and when I checked “DNS domain enabled” and “Apache website enabled” everything worked properly. I’m not really sure why these are “features” when the alias just doesn’t work without them enabled.
Thanks for posting this. The workflow for creating a domain alias should be simplified somehow to avoid users making this mistake. For a start an explaining text next to “Set up website for domain”: like “Leave this checked if you want your alias to point to an existing website” or similar.
I solved this alias problem by:
System Settings > Server Templates > Default Settings > Apache website > create alias website by: create permanent redirect virtual host.