By joelstahre
Im trying to configure a subdomain on one of my domains. I have one droplet, whit three domains on it.
domain1.com domain2.com domain3.com
i want to have a subdomain on one of them sub.domain3.com
here are my current records for each domain.
domain1.com A domain1.com directs to 11.11.11.11 CNAME www.domain1.com is an alias of domain1.com.
domain2.com A domain2.com directs to 11.11.11.11 CNAME www.domain2.com is an alias of domain2.com. CNAME *.domain2.com is an alias of domain2.com.
domain3.com (This is the one i want to have a subdomain on) A sub.domain3.com directs to 11.11.11.11 A domain3.com directs to 11.11.11.11
CNAME *.domain3.com is an alias of domain3.com. CNAME www.domain3.com is an alias of domain3.com. CNAME *.sub.domain3.com is an alias of sub.domain3.com.
when browsing to sub.domain3.com it will acctually direct me to domian1.com
Why is that? Can someone please help me what im doing wrong?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
How you’d go about setting this up really depends on what web server you’re using.
For example, with NGINX, you may setup three server blocks for your domains and then one more for the sub-domains. I’ve provided a basic overview below.
Since you’re not using a WildCard on this domain, the setup would be very simple.
server {
listen 80;
server_name domain1.com www.domain1.com;
...
...
}
Since you’re using a WildCard on this domain, we need to activate that in the server block.
server {
listen 80;
server_name domain2.com *.domain2.com;
...
...
}
Much like the second domain, we have a WildCard, so we need to activate it in the server block.
server {
listen 80;
server_name domain3.com *.domain3.com;
...
...
}
Sub-Domains can be treated just like your main domains, and we’d set them up the same. For each sub-domain, we create an entry and we can set them up with our without a WildCard. Since you’ve indicated that the sub-domain needs a WildCard, we’d activate it as we did with the domains.
server {
listen 80;
server_name sub.domain3.com *.sub.domain3.com;
...
...
}
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.