By figraham
Hello. I’ve been working on setting up an nginx server setup the goal is to eventually script adding new subdomains but I’ve been having trouble with my initial test. I’ve read through a bunch of tutorials and they gloss over setting up the DNS records so I have a feeling that’s where the problem is. Any help would be much appreciated. I’ve probably missed something small but I can’t figure it out for the life of me.
Goal:
Have static site that is createdby.fi and multiple other static (and possibly later non-static) sites on subdomains like sub.createdby.fi.
Current State:
createdby.fi loads correctly, but sub.createdby.fi show index.html page from createdby.fi
Details on Setup:
Running: Ubuntu 18.04.2 LTS
DNS settings on Digital Ocean:
| Type | Hostname | Value | TTL |
|---|---|---|---|
| A | sub.createdby.fi | directs to ip | 3600 |
| A | createdby.fi | directs to ip | 3600 |
Excluded domains CNAME (just www) and NS for brevity.
I briefly trying using a CNAME record but that didn’t fix the problem and one of the tutorials I read said A records were the way to go. If that’s wrong please correct me.
Hosts File:
127.0.1.1 createdby.fi
127.0.1.1 sub.createdby.fi
127.0.0.1 localhost
Nginx Config Files:
/etc/nginx/sites-available/createdby.fi (symbolic linked in sites-enabled)
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/createdby.fi;
index index.html;
server_name createby.fi www.createdby.fi;
location / {
try_files $uri $uri/ =404;
}
}
/etc/nginx/sites-available/sub.createdby.fi (symbolic linked in sites-enabled)
server {
listen 80;
listen [::]:80;
root /var/www/sub.createdby.fi;
index index.html;
server_name sub.createby.fi www.sub.createdby.fi;
location / {
try_files $uri $uri/ =404;
}
}
/var/www/createdby.fi and /var/www/sub.createdby.fi both have boilerplate html files with different different text.
server_names_hash_bucket_size 64; uncommented in /etc/nginx/nginx.conf otherwise unchanged
Nginx has been restarted and server was rebooted.
I’ve cleared the browser cache and even tried flushing dns and deleting temp files on my browser, so I don’t think that’s the problem.
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!
Hi, There is typo error in server name in both the blocks. In which case Request would be served by default server. server_name createby.fi Correction=> server_name createdby.fi
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.