Question

How to setup a droplet to serve a subdomain on a different domain

I have a domain mydomain.com and I set up a subdomain (sub.mydomain.com) which has SSL certificate associated with it with a redirect configured from HTTP to HTTPS which points to a droplet on DO, DNS record is properly setup.

Problem:

When I visit the link I get “no server IP address could not be found” or no data

licences.energycom.gov.gh is added on the droplet as a domain and when I try to install letsEncrypt SSL certificate using (https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-20-04) I get unable to install the certificate but the certificate and chain are stored. How do I correctly setup the droplet so I can install SSL and be able to serve the request and return data when accesses through the subdomain

What do I need to do for the droplet to serve the subdomain request with data,

Show comments

Submit an answer


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!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
November 12, 2022

Hi @lclp,

Do you have a Nginx configuration file for port 80/HTTP for your subdomain?

It sounds like Nginx can’t find your subdomain as it’s configured on it. Check the following article on how to do it.

https://www.digitalocean.com/community/tutorials/how-to-set-up-nginx-server-blocks-virtual-hosts-on-ubuntu-16-04#step-4-enabling-your-server-blocks-and-restart-nginx

Hi @lclp,

The preferred method for redirecting HTTP to HTTPS in Nginx is to set up a separate server block for each version of the site. You should avoid redirecting traffic by using the if policy, as it can cause unpredictable server behavior. Redirect HTTP to HTTPS per site.

You probably have a misplaced policy in subdomain configuration. Feel free to share your subdomain block.

Cheers,

Sergio Turpín

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up