Connect VPS with domain

cloudytechi147

New member
Registered
Joined
Dec 16, 2021
Messages
1
Points
1
I have a website with the frontend and backend hosted with different hosting providers. The frontend of the app is in Vercel while the backend is in Linode. I also bought a domain in Cheapname, namely example.com. Right now both example dot com and example.com redirect to the Vercel frontend app. The backend is hosted on a VPS and I'm using Nginx for the server. The backend can be accessed using the IP of the VPS.

What I want: Access the frontend app with example.com and example dot com (so far this part works), and access the backend when using the subdomain api.example.com (this does not).

What I have done so far: Changed the DNS for Cheapname and Vercel:

1639642799864.png

1639642857321.png

where xxx.xx.xx.xx is the IP address of the VPS

The Problem: When I try to access api.example.com it redirects me to https:\\api.example.com and it gives me a 404 error (Vercel 404!!!). I'm a newbie with DNS, I would appreciate any help!!! Thank you in advance! =)
 

The Boss

K Tysinger
Registered
Joined
Sep 25, 2019
Messages
24
Points
1
Your DNS is really a mess, but it looks like you have just about have it working anyway. If you change the nginx config from listen 80 to listen 443, it looks like it should work, although you will need to install an SSL cert to use the API without security errors. Port 80 = unsecured HTTP and Port 443 = secured HTTPS.

A few pointers. Use only secured connections for your API. You do not need both a cname and an A record for your API subdomain. Remove the cname. You are using the www cname incorrectly. Should be www example.com. Or just use the IP address like this:
A record www ip.address.all.numbers.here

Confused yet? It should look like this at namecheap:

A Record @ IP.to.frontend
A Record api IP.to.backend
Cname record www example.com

That's it. Add mail and whatever records later. If you have IPV6, do not reference it until you get this working. Adding an SSL cert may be the hardest part, why not hit up Linode tech support. If you ask them nicely, they will bend over backward for you. I don't see why you are being redirected from HTTP to HTTPS. Nginx config? Subdomain not pointing to the right place?
 
Last edited:
Older Threads
Recommended Threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top