Server Alias not Resolving to correct virtual server

13 posts / 0 new
Last post
#1 Thu, 01/17/2013 - 11:43
lewismc

Server Alias not Resolving to correct virtual server

Hi,

I set up a virtual server for site1.co.uk. And successfully added a server alias ( site1.com )

I recently set up a virtual server for site2.co.uk. However, my server alias ( site2.com ) that I created as an alias of site2.co.uk resolves to site1.co.uk?

I wondered 2 things:

  1. 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?

  2. 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?

Any assistance would be appreciated.

Thu, 01/17/2013 - 12:48
andreychek

Howdy,

Take a peek at the document here in the section "the wrong site shows up", that should assist you in figuring out what's going wrong there:

https://www.virtualmin.com/documentation/web/troubleshooting

If that doesn't help, let us know and we can do some more troubleshooting to figure out what is awry.

-Eric

Fri, 01/18/2013 - 08:28 (Reply to #2)
lewismc

Thanks Eric,

I have worked through the documentation...

error_log:

nothing stood out here other than a few file does not exist for a couple of images on both site1.co.uk and site2.co.uk

access_log:

Looking the the access_log for site1.co.uk I am getting lines showing site2.com such as: HTTP/1.1" 304 180 "http://site2.com/" "Mozilla/5.0

wrong site showing up:

  • My primary server is listed as eth1
  • 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?

Lewis

Fri, 01/18/2013 - 09:40
andreychek

Howdy,

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?

-Eric

Fri, 01/18/2013 - 11:35 (Reply to #4)
lewismc

Helloha,

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)?

Tue, 01/22/2013 - 09:52 (Reply to #5)
lewismc

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.

I switched the default domain in Server Configuration > Website Options from site1.co.uk to site2.co.uk and both site1.com and site2.com now default to site2.co.uk.

It almost feels like a permission based issue - but I don't have the knowledge authority to be so bold.

It's a small discovery I know but hope this helps.

Questions

Is there a way I can check this? Are there any configurations I should be looking at?

Thu, 01/24/2013 - 05:36 (Reply to #6)
lewismc

Hello Folks & Thanks Andreychek for your input.

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.

Lewis

Sun, 01/27/2013 - 23:20 (Reply to #7)
jasongayson

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! :)

Mon, 02/10/2014 - 12:10 (Reply to #8)
kdhannan

Thank you so much for posting this!

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.

Mon, 06/02/2014 - 14:44 (Reply to #9)
benjamin_dk

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.

Fri, 08/28/2015 - 03:00 (Reply to #10)
simon1066

Just adding my name to the list of those who benefited from this post.

Thank you.

Thu, 01/24/2013 - 09:35
tpnsolutions
tpnsolutions's picture

Hi,

Good to hear you resolved this. Sometimes it's the simple stuff that stumps us the most :-)

Best Regards,
Peter Knowles | TPN Solutions
Email: pknowles@tpnsolutions.com | Skype: tpnassist
Sun, 04/08/2018 - 21:06
gscerb

I solved this alias problem by: System Settings > Server Templates > Default Settings > Apache website > create alias website by: create permanent redirect virtual host.