Allow my customer to configure their own domain to the same application - node.js

I'm building a shopify-like application. right now when a customer creates a store, he gets some subdomain like https://customer1.shopify-like.com
My Shopify-like frontend application hosts on AWS/ec2 and built with react.js. So, when you visit customer1.shopify-like.com my Nginx(ec2) configuration catches all *.shopify-like.com and load the same react-application (proxy_pass to http://frontend:80, all services up by docker-compose).
and it works fine.
the question is how to allow my customer to configure their own domain as Shopify does.
[docs link][1]
Set up your existing domain to connect to Shopify If you've purchased
your domain through a third party, then you need to edit the following
DNS settings:
Your A record should point to Shopify's IP address, which is
23.227.38.65 Copy
Your www CNAME record should point to shops.myshopify.com Copy.
why Shopify asks you to set CNAME to shops.myshopify.com? what's the proposal?
should I ask my customer to configure CNAME to customer1.shopify-like.com and A Record to my ec2 IP?
if yes, why? because if they just configure the A Record to my ec2 IP. could I catch all requests with Nginx and proxy_pass to my frontend app?
[1]: https://help.shopify.com/en/manual/domains/add-a-domain/using-existing-domains/connecting-domains

Related

Programmatically Connect domains to servers

I want to create a simple web app. where user can have a form to add domain and directory name( that is already created on our server ). And it simply starts pointing the domain to that directory. What apis should I need for this? Hosting and domains can be bought from same brand, like GoDady.
Cloudflare has an API to add DNS records.
However, if you go this route, these are the prerequisites:
User's domain must already be activated in Cloudflare. At least partial-setup with Cloudflare's hosting partner (Siteground etc which have Cloudflare integrations built-in) or full-setup (the domain's authoritative nameserver points to Cloudflare).
User must trust you with their email address linked to their Cloudflare account and their Global API key.
Your web app can then make the API call to the endpoint and Cloudflare will create the appropriate DNS records to point to your server.

Connecting my domain name on digital ocean droplet

I created a small hello world node app, then i hosted the app on digital ocean droplet, after that i can access my application on http://my_public_ip:3000
Felt happy 😍
Then i bought a domain name called helloworld.tk free domain from freenom.com
After that i install nginx as a webserver in my droplet then i added a reverse proxy code in /etc/nginx/sites-enable/default
My code looks like:
server {
listen 80;
server_name helloworld.tk
location / {
proxy_pass http://localhost:3000;
}
}
After that i went to domain management panel in my freenom.com and set url forwarding to http://my_public_ip
So if i enter my domain name helloworld.tk in browser my node app successfully works 🤩 but wait what 🤔 my ip address is showing on left side below corner on chrome and if i refresh the page multiple times i get
402 Too many request error page on nginx
So i deleted my url forwarding and in my domain management panel instead of url forwarding i set my nameservers like this ns1.digitalocean.com bla.bla.bla...
Then i added my domain in my digitalocean panel. Now yes everything is working perfect.
If i hit my url no ip address is showing, also no too many request errors 😌
My node app successfully getting executed!
Wait i am a beginner for hosting node app, so i need help whether it is correct good setup for nodeapp on production?
What is the difference between url forwarding and nameservers? Whether my nginx reverse proxy code is correct? is my reverse proxy working correctly?
NOTE: I used pm2 for running node app on background.
First, remove the forwarding and you need to change the nameservers of the domain in your domain DNS management if your domain is somewhere other than DigitalOcean
Add below nameservers:
ns1.digitalocean.com
ns2.digitalocean.com
ns3.digitalocean.com
Now check if they are propagating by using whatsmydns.net (Enter your IP and change click on A and select NS and click Search)
Once they are propagating, add the domain to your DigitalOcean account.
Go to your DigitalOcean Dashboard and click on Networking.
Add a domain and click Save.
Then Edit the domain and add the Droplet to the Domain and save.
Now click on the domain name and an A record which points to your droplet.
Hope this will resolve your issue.
Go back to your DNS domain registrar ( freenom.com ) and remove mention of digitalocean nameservers and put back its own default frenom.com nameservers ... also on freenom.com assure you have defined a Type A record to point to your machine's external IP address
Your nginx config looks OK
this should work ... now had you defined digitalocean nameservers in your freecon.com registrar you would have then needed to go to https://cloud.digitalocean.com/networking/ and set up your Type A record there ... its critical to know the location of your nameservers determines where your Type A record must live
What you have to do is create a droplet in DigitalOcean and then add your domain name to the droplet in the Networking tab. You have to add both the non-www and www versions so the domain will be pointed correctly. You have to set the A records for those two to the IP of the droplet that DigitalOcean assigned to it.
Then from your GoDaddy/your domain manager, you have to go to ManageDNS and change the default GoDaddy name servers with those of DigitalOcean. Save it and you are done.
Wait for up to 24 hours and test the domain with check-host.net If all done correctly the domain should point to the servers of DigitalOcean in the city you have selected.

How to allow CNAME pointed to my server / how to use subdomain for a different server?

We create custom web apps for businesses and for the first time a client of ours has asked that instead of using our subdomain and instead of using a custom domain for their web app they would like to use their own subdomain for a domain currently hosted on another server.
For instance our domain is webapp.com and their domain is business.com. They would like app.business.com to be point to our name servers so we can continue hosting the web app for them.
I know it's possible to do this because we currently have outgoing CNAMEs on our server for help desks, etc, that aren't hosted on our own server but are using subdomains of ours.
Could you help me with what our client has to do on their zone editing side and what we need to do on our WHM/cPanel side to allow this?
NOTE: We had the client create a CNAME for app.business.com. pointed to our nameserver ns1.webapp.com and then we created an add-on domain for business.com and subdomain for app.business.com but when you try to visit app.business.com it gets the "Sorry!" cPanel page.
Thank you!
Alright I figured out how to do it on my own after a lot of testing & thought I'd post here to help others out in case they run across this in the future.
For the server with the subdomain on it have them create an 'A' record for that subdomain pointing to your server's IP address like so:
subdomain.business.com. ((note the extra period at the end is required))
TTL: 14400
Record Type: A
Pointing To: Your server's IP address.
Now on your server's cPanel you will need to create an addon domain for THAT subdomain (ie subdomain.business.com) - not for the actual business.com domain but for the entire subdomain subdomain.business.com with the folder being the root folder wherever you would like it to show.
That worked for me!
The CNAME should not point to your nameserver but your subdomain f.e. client1.webapp.com.
An other solution could be to add the subdomain app.business.com to your server and the client add an A record for the subdomain to your ip.

Pointing same domain to different app service in Azure

I am using Azure App Service to host my NodeExpress application, I am right now stuck at a very strange requirement.
I have 2 different azure app services.
1) myApp
2) sampleApp
I have a domain pointed at myApp. (Added hostname www.myapp.com)
now I want to delete myApp and shift my hostname (www.myapp.com) to sampleApp.
now my Question is,
will it change my IP Address? (This I think it would because I haven't bought any static IP)
if my app service pointing IP is changed, will I have to do anything with the domain DNS manager to move www.myapp.com in hostnames of sample app?
I don't have access to DNS Manager because client has it. I have to tell client to add CNAME to verify domain ownership. I want to point this domain to different app service without adding delay of asking my client to change its cname to verify domain ownership.
You can actually migrate the domainname without downtime by using a verify record. Just create the record:
awverify.www.mydomain.com CNAME mynewnodeapp1.azurewebsites.net
That will enable you to add the hostname www.domain.com to sampleApp in azure (and add an SSL binding).
Source: https://learn.microsoft.com/en-us/azure/app-service/manage-custom-dns-migrate-domain
You have to register the new CNAME from your web application in the DNS server before adding it to Azure App Service. Right now you have something like this:
www.mydomain.com CNAME mynodeapp1.azurewebsites.net
First, change it to your new application address:
www.mydomain.com CNAME mynewnodeapp1.azurewebsites.net
And then add the custom domain to your new web application.
App Service does provide you with a public IP address, but it's not guaranteed to remain the same, although it's unlikely to change. Said that, as long as you keep using CNAME, you shouldn't have any problems. If you delete the original app and recreate using the same Azure FQDN, then you don't need to change anything on customer DNS settings, Azure will be able to verify the domain successfully in this case.

How to connect one of primary domain access with another subdomain

I have domain coupen.tk and a sub domain coupons.yadvi.com.I have web data in coupons.yadvi.com. i want so DNS configuration that if any one visit Coupen.tk they can see all information of coupon.yadvi.com but the link should be shown of coupen.tk not of coupons.yadvi.com
i have added the ip address of yadvi.com in coupoen.tk DNS A Record ,Ip Address of yadvi.com which will be same for coupons.yadvi.com.
coupen.tk needs to point to the same A record IP address as coupons.yadvi.com, so they both resolve to the same server. That server then needs to be configured to serve the same site for requests to both domains.
The usual way to do that would be to make coupen.tk the "master" A record and configure coupons.yadvi.com as CNAME coupen.tk, so it points to that master record. The web server still needs to be configured to serve the same site for either domain.
Failing that, you'll need to set up a reverse proxy server which literally forwards requests for one domain to the other.

Resources