Multiple Virtual Servers, DNS and Domain Names

5 posts / 0 new
Last post
#1 Wed, 02/01/2017 - 18:20
BobGeorge

Multiple Virtual Servers, DNS and Domain Names

Okay, after initially setting up my test server, with a few virtual servers using Virtualmin, behind a NAT to just get things up and running to learn how this works, the next stage is learning how to make the virtual servers' websites publicly accessible to the Internet.

I have the server machine now sitting on the end of a static IP address and I have some spare domain names for testing purposes. I will be hosting a few virtual servers on this server and each one will have its own separate domain name.

Do I simply create an "A" record for the domain name that points to the server's static IP with the company I bought the domain name from and that's it? That is, Apache will pick up on the domain name and serve the corresponding named virtual host, so I don't need to do anything more?

Or do I need to be running a DNS server myself, with entries for each domain name / virtual host, and then I point the domain name at my server's name servers to resolve which one is which?

I've not done this before. I'm not exactly sure how the DNS records need to be set up to make this work and whether I do or don't need to be running my own DNS server or not. Virtualmin will set up the required DNS records for me if I run my own DNS server, but do I even need to do this in my situation?

For example, with Virtualmin, I've created the virtual servers "website1.com" and "website2.com" on the server. I have also purchased the domain names "website1.com" and "website2.com" from a registrar and can edit the DNS records for those domain names.

How do I hook it up so that when someone types "website1.com" into their browser, Apache will end up serving the "website1.com" virtual host to them? And, of course, similarly with "website2.com" but serving them the "website2.com" website instead.

Just an "A" record that points to that static IP address? These are top-level domains. Do I need a DNS server only for subdomains or also for top-level domains as well?

Basically, I'm just generally confused as to how this DNS stuff is supposed to be set up, as I've not done it before.

Thu, 02/09/2017 - 21:51
tpnsolutions
tpnsolutions's picture

Hi,

If you only have a single static IP, it's probably easiest to simply point all your domains via your domain registration provider's DNS settings to the static IP via an A record.

Setting up multiple domains in Virtualmin with the same "shared" IP address will setup what's called "name-based" hosting, where Apache will figure out automatically which site to display based on the domain sent by the browser.

If you have any further questions, or need any assistance please feel free to reach out to me any time.

Best Regards,
Peter Knowles
TPN Solutions

Email: pknowles@tpnsolutions.com
Skype: tpnassist
Best Regards,
Peter Knowles | TPN Solutions
Email: pknowles@tpnsolutions.com | Skype: tpnassist
Fri, 02/10/2017 - 17:42 (Reply to #2)
BobGeorge

Ah, right. So I do just create the appropriate "A" record pointed at my static IP and Apache will sort out the rest. Good to know.

I'll still be using a DNS server on the "localhost" of my development machine, though, as being able to just call up websites by name in a browser - without having to mess around with FTP or anything - makes PHP development so much easier. But, okay, I don't need a DNS server on the actual live server, as Apache will handle things there.

Thanks for the response.

Sun, 02/12/2017 - 20:58 (Reply to #3)
tpnsolutions
tpnsolutions's picture

Hey,

No worries, if you have any other questions feel free to either post them here or fire me an email. Always happy to lend my assistance :-)

Best Regards,
Peter Knowles
TPN Solutions

Email: pknowles@tpnsolutions.com
Best Regards,
Peter Knowles | TPN Solutions
Email: pknowles@tpnsolutions.com | Skype: tpnassist
Tue, 04/11/2017 - 14:08
thomnet

I have a similar question. Let me start off by saying the primary reason I decided to use Web/Virtualmin was to ease the task of dealing with email. I find it a pain to setup as it seems to involves so many subsystems (spam, dns, dkim, spf ...).

I have 2 domains purchased at a registrar. One is just for my personal dev use and may contain a number of virtual sub-servers. I'll call this Master domain A. It will also host a number of email accounts. It may host other tld domains down the road as necessary. Q1: Are sub-servers in Virtualmin the same as subdomains? Q2: Does it ever make sense to use a sub-server for a tld?

The other domain I run is for a local group which has an SMF forum and Wordpress website. It primarily needs to SEND email, tho it also makes sense to receive email for webmaster, abuse etc.

In general it seems to make more sense to me to run my own nameserver so I have full control of the DNS entries I need rather than rely on the registrar, who may decide to change their UI, or experience outage for some reason. The registrar actually said to point both ns1.domainA.tld AND ns2.domainA.tld to my VPS primary address that hosts my nameserver. So I will change the nameservers on the registrar for domain A to point to my VPS.

Q3: If I create sub-servers on domainA.tld, for example sub1.domainA.tld will the name server manage routing email and web traffic to the appropriate sub-servers? My assumption is yes, and that seems straightforward to me.

The confusion comes from how to handle other domains. The VPS only hosts 1 nameserver. I understand bind can be configured to handle multiple domains, but I'm not sure how it traffic is routed for email or webservers or how to set it up.

Q4: Would I ALSO point the nameservers for domainB to the same IP address as was used for domainA? I have 2 static IP addresses on this VPS, the primary IP for domainA and the nameservers and a second IP provided by the VPS hosting company I have configured as a "virtual IP" on eth0:1. The webtraffic can be routed based on IP, I can see how that works. Not sure about email for domainB and what the nameserver's role in that is.

Many thanks for any info you can provide :)

Topic locked