Anyone know how to connect to custom domain?

I mean suppose I am creating a bloggin app, where users should be able to connect to thier custom domain, how can we do it?
8 Replies
Lopen
Lopen17mo ago
When they connect the domain what happens?
whizzy
whizzyOP17mo ago
They will be get their own site my the blogs they create through my site will reflect on their domain
pagwin
pagwin17mo ago
you can have them set a cname record like vercel does and then in the http request look at the Host header to figure out which blog to show
whizzy
whizzyOP17mo ago
Hmm !! Kinda understood but didn’t get it !! How do I manage the dns how to do trans the data from my website to the desired domain ?
Lopen
Lopen17mo ago
Is the blog managed on your platform? Apache or ngnix or apache or what? Are on your own vps? Because this determine the approach you go If i were to implement such, my approach would be to 1) Get a vps server 2) using nginx Then, to set up the custom domain stuff: The user will need to set their DNs to point to your server For example: you can give them your server ip Name: www Value: 1.2.3.4 (your server's IP address) So when they set this up, whenever some hits their custom domain, the requests will be redirected to your server So now the next thing is how to handle the requests that come into your server from their custom domain. I don't know how you're severing your blog content, so i will assume that you use path Eg: yourmaindomain.com/john My nginx config will look like this
server {
listen 80;
server_name theircustomdomain.com;
location / { proxy_pass http://yourmaindomain.com/john; } }
server {
listen 80;
server_name theircustomdomain.com;
location / { proxy_pass http://yourmaindomain.com/john; } }
You can use npm packages like
node-nginx
node-nginx
to dynamic update and add the above Or you can use fs or write a bash script, then run it via child process This is just a rough sketch, but i am sure you get the whole picture now?
Eternal Mori
Eternal Mori17mo ago
You can also use a CNAME record like pagwin said, but set it up with a providers API. for example, you can create new domains and set a CNAME record with the vercel API so your users dont have to set it up!
pagwin
pagwin17mo ago
you don't manage the dns, you have the user setup a CNAME record so that the domain will point to your server(s) then whenever a request reaches your server(s) you figure out which domain it's for and respond appropriately yeah having users transfer their domain to you to manage through some provider's api is also a valid way rather than them setting a CNAME record manually
whizzy
whizzyOP17mo ago
thank you guys, am really glad that you took the time to answer, I will try this approach @pagwin @perkamentus @lopen3
Want results from more Discord servers?
Add your server