How do I add a subdomain to a Linode with Ubuntu 20.04 image?
Hi guys,
I recently deployed my flask application on a GoDaddy domain e.g. (www.example.com) using NGINX, Ubuntu 20.04 on Linode with all the configurations working fine on the main domain.
I followed various tutorials to deploy e.g. "test.example.com" subdomain and followed the conventional steps:
1. fix A record test.example.com on linode GUI
2. sudo nano /etc/nginx/sites-available/test.example.com
3.
server {
listen 80;
root /var/www/test.example.com;
index index.html index.htm index.nginx-debian.html;
server_name test.example.com www.test.example.com;
location / {
try_files $uri $uri/ =404;
}
}
4. ln -s /etc/sites-available/test.example.com /etc/sites-enabled/test.example.com
5. service nginx restart
However no luck. I'm wondering if it's a GoDaddy issue or if I am missing something along the way?
Thanks in advance!
5 Replies
We'll need to know in what way the subdomain is failing in order to be able to troubleshoot this effectively. Any error output you can provide should be helpful.
The NGINX server block from your paste looks good to me, so I'm assuming the issue lies somewhere with the subdomain's DNS configuration.
What sort of error message is thrown when you try to visit the subdomain in a browser? (Not resolved, connection refused, connection timed out, etc)
If there is a resolution error, the problem is likely related to the subdomain's configuration with the Linode name server. A timeout or refusal points to a likely issue with NGINX or the Linode's configuration.
You mentioned that you've configured the Domain in the Cloud Manager and the main site works, so the problem is likely not with GoDaddy.
Hi @_Brian thank you for your response.
I think the issue is either my DNS configuration or there is something to do with Linodes DNS servers not propagating properly.
On the browser is saying "We can’t connect to the server at test.domain.com".
The output of dig command:
dig test.domain.com @ns2.linode.com
; <<>> DiG 9.16.1-Ubuntu <<>> test.domain.com @ns2.linode.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: REFUSED, id: 27615
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
;; QUESTION SECTION:
;test.domain.com. IN A
;; Query time: 0 msec
;; SERVER: 2400:cb00:2049:1::a29f:1827#53(2400:cb00:2049:1::a29f:1827)
;; WHEN: Fri Jan 08 15:56:02 UTC 2021
;; MSG SIZE rcvd: 46
Also the DNS only shows results for the www.domain.com but not for the domain.com
My A records at the moment are
- www.domain.com
- test
However I have tried various other A records including
- www
- domain.com
- *
Any help is appreciated!
Thank you.
Hey @mojodigital
I may have cheated a bit by looking at your Linode account, but I think I have your answer.
When you add a Domain through the Linode Cloud Manager, you want to omit the "www" piece of the domain in the name field.
Correct:
example.com
Incorrect:
www.example.com
You should still add an A record for the subdomain "www", but adding them after using "www" in the name field makes all subdomains become subdomains of the www.
For example, if you were to add a subdomain "crm" you would then have "crm.www.example.com" - which would resolve if you were to check it.
Hope this helps. Good luck with the site! :)
@_Brian it seems it has now been resolved!
It appears that I had read somewhere that when putting in an A record, you should leave the hostname blank, so that automatically inputted www.
example.com, so I went along with it.
After a long and sleepless night, learning NGINX, bash and Linode inside out 😂… must say happy new year to you and the Linode team!
Thanks for checking this out so quickly and getting back to me.
Have a great day.