I’m trying to add a subdomain to my nginx server, and can’t seem to get it working. Here’s the config file for my primary server:
server { listen 80; server_name www.kevin-whitaker.net; rewrite ^/(.*) http://kevin-whitaker.net permanent; }
server { listen 80; server_name kevin-whitaker.net;
access_log /home/admin/public_html/kevin-whitaker.net/log/access.log;
error_log /home/admin/public_html/kevin-whitaker.net/log/error.log;
root /home/admin/public_html/kevin-whitaker.net/public/;
index index.html;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect false;
if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}
if (-f $request_filename.html) {
rewrite (.*) $1.html break;
}
}
}
What I would like now is to create a subdomain as following:
server { server_name devcloud.artworked.com; root /usr/share/nginx/html/server/devcloud; }
Where I’m I going wrong ?
And does creating a subdomain on Nginx requires DNS intry such as an A record or a CNAME as there is conflicting information online.
Thanks for your help.
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 Riad, <br> <br>Could you be a little more explicit about what doesn’t work? What error messages are you receiving when trying to access the page? <br> <br>Take a look at this article for some help with setting up DNS using DigitalOcean’s panel: <br> <br>https://www.digitalocean.com/community/articles/how-to-set-up-and-test-dns-subdomains-with-digitalocean-s-dns-panel
I’m trying to point this subdomain <br> <br>http://devcloud.artworked.com to this path… <br> <br>http://MY_SERVER_IP/server/devcloud/ <br> <br>When I hit http://devcloud.artworked.com I get the DNS error “You tried to visit devcloud.artworked.com, which is not loading.” <br> <br>I’ve already set an A Record <br> <br>devcloud in A MY_SERVER_IP. <br> <br>I’ve created a fairly simple nginx block as well… <br> <br>server_name devcloud.artworked.com; <br> root /usr/share/nginx/html/server/devcloud; <br> index index.php index.html; <br> <br> <br>Where I’m I missing ? <br>
It doesn’t look like the subdomain was added. Did you add it to Cloudflare’s DNS control panel?
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.