PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, June 24, 2022

[FIXED] How to allow clients to set up custom domains for their own pages on a service website?

 June 24, 2022     .htaccess, cname, node.js, redirect, reverse-proxy     No comments   

Issue

I want to implement the same functionality Intercom provides to their clients; they allow the implementation of Custom Domains for Articles. I'm not quite sure how they go about their method of implementation, or what they're doing behind the scenes, exactly.

Take the following scenario; a client (company NorthWind), has a subdomain on my company's website (northwind.example.com).

The following is to occur:

  • If a user types northwind.example.com, they go to northwind.example.com and northwind.example.com appears in the url bar.
  • If a user types example.northwind.com, they go to northwind.example.com and example.northwind.com appears in the url bar.

The difference between the way Intercom implements it and the way I wish to implement it is that I'm using a subdomain, not a directory, as seen in Intercom's help article linked above.


Considering my website runs on Nginx, NodeJS, and MongoDB, here's what I came up with so far:

  • Client registers a CName record on their domain provider to point to their page on my website.
  • Client provides the CName record they used to my website (register it through a form).
  • I save a record in MongoDB for the company and their custom domain.
  • I register, or re-register, the reverse proxies of my website, using redbird to allow the redirection to go through.

I've already looked into Redirect Web Page to Another Site Without Changing URL and Does a Cname Change the URL that the Browser Displays.

Am I on the right path, or is there a better method?


Solution

I decided to ask Intercom themselves, through their support channel, for an answer, and I was given the following response:

This isn't actually something we do anything too special with, it is all to do with the configuration of the web server, both on our side and the side of the client.

This stackoverflow goes into more details on this, but keep in mind that whilst it is a ruby StackOverflow - it focuses on the web server set up, in this case nginx - but it could be any web server software.

How to preserve request url with nginx proxy_pass

This then allows your service to receive the requests, but also have access to the original server address - we then ask our customers to provide the custom domain they are using within their Article Setting to help us translate the server address to the correct help center.

I do hope this helps, if you do have any follow up questions I'm happy to try and help, but as you mentioned this does fall out of the scope of our team so the help I can provide may be limited.

Quite happy with the response, as they went above and beyond for me. Basically, the path I was on was the correct one. I decided to leave the question to help others. I also found the following related questions:

  • How do I enable custom domains for my users?
  • How to give cname forward support to saas software
  • Custom domain feature for saas product customers

Good luck to those who find this.



Answered By - yaserso
Answer Checked By - Pedro (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing