creating sub-domains - on the server - with DNS records that can point to the same server

thedighubs

Member
Nov 21, 2024
186
18
41
good day, dear friends, :)


I have a root server - and i have a certain project in mind:
How easy is it to set up the following arrangement on such a server—if I have a relatively generic domain: let's say, for example, cafe.com?

Can we then create subdomains like these:

Code:
central.cafe.com
clinic.cafe.com
school.cafe.com
xyz.cafe.com

How would that work technically—what are the server requirements?

Well i suppose that this is actually a classic setup, and with a root server and it's very doable.


the Basic Idea -.. it looks somewhat like so: i want to have some Subdomains like

Code:
central.cafe.com
clinic.cafe.com
school.cafe.com
xyz.cafe.com

some assumptions: arent they are simply hmmm - "DNS records" that can point to the same server (or different servers).

with the two levels:

1. DNS (Domain Name System) → determines where `central.cafe.com` points.
2. Web server (e.g., Nginx, Apache) → decides what is delivered there.

hmmm - can i go like so? Are these assumptions pointing intot the right way?
look forward to hear from you


greetings

update:
ps. hmm - i guess that we access to the domain's DNS management

There, i can create an A record or CNAME record for each subdomain:
for example like so: (if the server has, for example, 123.45.67.89):


Code:
central A 123.45.67.89
clinic A 123.45.67.89
 
Last edited:

Red Squirrel

No Lifer
May 24, 2003
70,958
13,934
126
www.anyf.ca
I think you answered your own question, you can just create cname entries assuming you want the subdomains to point to same IP.

In apache you then have to create vitualhosts for each sub domain, if you want them to go to different sites. I usually like to do a virtualhost that is HTTP first (no SSL) then get SSL cert (ex: through Letsencrypt) which requires validation and for the host to work. Once that's done, create the SSL virtualhost then change the non SSL one just setup a redirect to the SSL one, if you want to force HTTPS.

Ex:

Code:
<VirtualHost *:80>
    DocumentRoot /localdata/www/cafe/central/www/
    ServerName central.cafe.com

redirect permanent / https://central.cafe.com

<directory "/localdata/www/cafe/central/www/">
options +indexes
allowoverride all
require all granted
</directory>

</virtualhost>


<virtualhost *:443>
documentroot /localdata/www/cafe/central/www/
servername central.cafe.com


<directory "/localdata/www/cafe/central/www/">
options +indexes
allowoverride all
require all granted
</directory>

SSLCertificateFile /localdata/home/cafe/.acme/certs/central.cafe.com/central.cafe.com.cer
SSLCertificateKeyFile /localdata/home/cafe/.acme/certs/central.cafe.com/central.cafe.com.key
SSLCertificateChainFile /localdata/home/cafe/.acme/certs/central.cafe.com/fullchain.cer
</virtualhost>
 
  • Love
Reactions: thedighubs

thedighubs

Member
Nov 21, 2024
186
18
41
hello and good day dear RedSqurrel, :)

first of all : many thanks for the quick reply - i am really happy to hear form you.
this is only a short note - a short answer - i am a bit short of time at the moment- ill be back later...again.

I think you answered your own question, you can just create cname entries assuming you want the subdomains to point to same IP.

thank you. i was a bit unsure - about the process. But i am so glad that you have answered here.

this is very thoughtful that you have explained me the details.

In apache you then have to create vitualhosts for each sub domain, if you want them to go to different sites. I usually like to do a virtualhost that is HTTP first (no SSL) then get SSL cert (ex: through Letsencrypt) which requires validation and for the host to work. Once that's done, create the SSL virtualhost then change the non SSL one just setup a redirect to the SSL one, if you want to force HTTPS.


thank you very much - this is very convincing! Thanks for the in-depth going explanation.


I am so glad to be here in this great place.

i have to leave the house - but i am getting back online later the eveing.

greetings:)
 

Charmonium

Lifer
May 15, 2015
10,610
3,589
136
good day, dear friends, :)


I have a root server - and i have a certain project in mind:
How easy is it to set up the following arrangement on such a server—if I have a relatively generic domain: let's say, for example, cafe.com?

Can we then create subdomains like these:

Code:
central.cafe.com
clinic.cafe.com
school.cafe.com
xyz.cafe.com

How would that work technically—what are the server requirements?

Well i suppose that this is actually a classic setup, and with a root server and it's very doable.


the Basic Idea -.. it looks somewhat like so: i want to have some Subdomains like

Code:
central.cafe.com
clinic.cafe.com
school.cafe.com
xyz.cafe.com

some assumptions: arent they are simply hmmm - "DNS records" that can point to the same server (or different servers).

with the two levels:

1. DNS (Domain Name System) → determines where `central.cafe.com` points.
2. Web server (e.g., Nginx, Apache) → decides what is delivered there.

hmmm - can i go like so? Are these assumptions pointing intot the right way?
look forward to hear from you


greetings

update:
ps. hmm - i guess that we access to the domain's DNS management

There, i can create an A record or CNAME record for each subdomain:
for example like so: (if the server has, for example, 123.45.67.89):


Code:
central A 123.45.67.89
clinic A 123.45.67.89
Where do you think you are? A computer forum?

Oops. . .

Never mind ;)
 

thedighubs

Member
Nov 21, 2024
186
18
41
hi there - hello again, good day dear Charmonium :)

thank you for the reply - :)

Where do you think you are? A computer forum?

hehe - youre right -i don't take for granted the amount of help you receive here.
I'm delighted about it – about the exchange of ideas and help in soo many cases.

and its great to see that we can disucss all that things - from Server to RasPi, from Tablet to NoteTaking-Systems and so on...

this is great - a awesome experience,

have a great day
greetings:)
 
  • Like
Reactions: Charmonium