Question

Point a Subdomain to Droplet

I have a domain example.com that I use for the frontend of my application, hosted on Vercel. I’ve passed the DNS records provided by Vercel to my registrar (Squarespace). If I access example.com the frontend is being displayed.

Now, I have a droplet for the backend of my application which for now only has some dependencies and Nginx installed. If I visit http://droplet-ip the default Nginx page is displayed. How can I achieve the same behaviour by visiting http://api.example.com ?

I’ve added a new DNS record to Squarespace:

  • Host: api | Type: A | Data: <droplet’s ipv4>

But for some reason when I try to visit http://api.example.com it redirects me to https://api.example.com and a Vercel specific error is being displayed “Deployment not found”. What am I doing wrong here?

I did not modify any NS and if I use the DNS lookup tool (https://www.digitalocean.com/community/tools/dns) to search for api.example.com it displays Owner: DIGITALOCEAN


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 6, 2023

Heya @dragos1412,

First, you need to make sure your DNS is working properly. Try to do a ping

ping -c 2 api.example.com

Does it return your Droplet’s IP address? If, yes, then good!

As for Nginx, you need to configure your api.example.com domain in your Nginx configuration. Check the following docs :

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-22-04#step-5-setting-up-server-blocks-recommended

It should help with what you need.

Try DigitalOcean for free

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

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel