1

I am creating Multi-tenant website using Laravel.

Does Laravel forge provide domain mapping API?

I would like to let users use their own domain instead of our subdomain.

For example: user will get subdomain in our website.

https://username.mywebsite.com

And if he has his domain userdomain.com, he will be able to change CNAME in domain registrar so that he can use his own domain instead of our website subdomain.

And also on my side, I will need to park that domain on the my project domain.

https://username.mywebsite.com // subdomain of our website.
https://userdomain.com // user's own domain

For now, I am using Cpanel API to park user's domain on our website.

I am quite new on laravel forge and if there is the way to park domain using laravel forge API, it will be great.

Any suggestion would be highly appreciated.

LoveCoding
  • 1,121
  • 2
  • 12
  • 33

1 Answers1

1

This is not possible directly from the Forge UI.

However, you could comfortably create a new alias for each new client via the API, specifically the update site endpoint: https://forge.laravel.com/api-documentation#update-site

Just be mindful you will need to pass the full list of aliases each time, including your mywebsite.com domain. This can easily be done by fetching the site first.

Chris
  • 54,599
  • 30
  • 149
  • 186
  • Hi Thanks! My original intend was to solve custom domain's SSL in laravel multi-tenant project. Do you have any idea for it? – LoveCoding Sep 14 '20 at 18:00
  • I would still apply the same logic - update the alias list for each new site and then issue a new SSL cert through the API. You will need to be extremely vigilant in your approach though - you would need to add the new alias, create a new cert (with all the aliases) and then remove the old cert – Chris Sep 15 '20 at 02:09
  • If there are 10, 000 custom domains, then do I need submit them all for even one new domain? – LoveCoding Sep 17 '20 at 02:00
  • 1
    For Forge, yes I would say so. However if you are talking 10,000 custom domains its probably better to write your own nginx config to handle all inbound domains (you can edit the nginx config within Forge). For example: https://stackoverflow.com/questions/9454764/nginx-server-name-wildcard-or-catch-all – Chris Sep 17 '20 at 02:52
  • well, but custom domains will be added automatically. So I was just looking for API for it. – LoveCoding Sep 17 '20 at 03:03
  • 1
    There is no real direct API for that specfic issue (though you can edit the nginx config via the API). So you can either add a new alias each time (first comment above) via the API or create a generic catch all nginx config (you only need to do this once) – Chris Sep 17 '20 at 03:36