Web Hosting

Connect VPS with domain

Topic: Connect VPS with domain  (Read 120 times)

Offline cloudytechi147

  • Newbie
  • *
  • Posts: 1
  • iTrader: +0/-0
    • View Profile
Connect VPS with domain
« on: December 16, 2021, 03:58:20 PM »
I have a website with the frontend and backend hosted with different hosting providers. The fronted 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 www.example.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 cheapest vps hosting.

What I want: Access the frontend app with example.com and www.example.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:

Code: [Select]
A Record    @ 76.76.21.21
CNAME Record    www cname.vercel-dns.com.
CAA Record  0 issue "letsencrypt.org"

Because I want the backend to only be accessed through api.example.com I set the configuration of nginx as follows:

Code: [Select]
server {
    listen 80;
    server_name api.exaple.com;
    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/myuser/myproject;
    }
    location / {
        include proxy_params;
        proxy_pass http://unix:/home/myuser/myproject/myproject.sock;
    }
    client_max_body_size 100M;
}

Then, I put this on Namecheap:

Code: [Select]
A Record    api    xxx.xx.xx.xx
CNAME Record    api  xxx-xx-xx-xx.ip.linodeusercontent.com.

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! =)
« Last Edit: December 17, 2021, 05:07:19 PM by Kailash »
VPS Hosting - AccuWebHosting

Offline Kailash

  • Web Hosting Master
  • *****
  • Administrator
  • Posts: 657
  • iTrader: +153/-0
    • View Profile
Re: Connect VPS with domain
« Reply #1 on: December 17, 2021, 05:09:48 PM »
If your subdomain is redirecting to wrong URL, it is most likely related to your nginx configuration or .htaccess rule issue. You should review your .htaccess rule and nginx configuration. Also, it is recommended to activate free Let's Encrypt SSL so that you can use HTTPs for your subdomain.

- Kailash
Bluehost hosting Divi WordPress Theme

Various Connection Strings to Connect to an Access DB

Started by TechBoard MS Access

Replies: 3
Views: 6379
Last post October 13, 2015, 09:54:54 AM
by jeffreykirwin
PHPMailer error :: unable to connect to server

Started by JohnBoard cPanel/WHM

Replies: 1
Views: 4811
Last post April 24, 2008, 01:32:15 AM
by Kailash
cPanel Roundcube cannot connect with database

Started by ChrisBoard cPanel/WHM

Replies: 1
Views: 1793
Last post October 31, 2019, 11:30:26 AM
by Kailash