Custom domains for multi-tenancy

default discord avatar
taun2160
3 months ago
22

What does Payload define as a custom domain and where can I learn more? If I don't use Payload Cloud, Is there a limit to the amount of custom domains? Eg. user1.website.com, user2.website.com, or is that not a custom domain and I can have infinite using Payload Cloud? I'd like to automate the whole system - no manual configuration for new users.

  • default discord avatar
    philiposaurus
    3 months ago

    I am not aware of Payload by itself is able to - from 1 node server - handle multiple subdomains. I think you'd have to manage your DNS to point all to a single server behind the scenes or do something with a reverse proxy.


    Another option is to have multiple servers running the same code and differentiating using .env var.

  • default discord avatar
    taun2160
    3 months ago

    Ideally I'd like to create a website wherein the user registers, makes a payment and receives their own domain, like user.blogspot.com . I don't want to manually deploy and configure anything.



    Custom domains for multi-tenancy

  • default discord avatar
    sawariz0r
    3 months ago

    ChatGPT has no reference of Payload past 2021. Keep that in mind when using it for technical solutions 🙂

  • default discord avatar
    taun2160
    3 months ago

    Does Payload offer a simpler solution for this using their Cloud? If so, anyone know any details, such as pricing?



    If it's far simpler to instead have www.website.com/user1 - I'm interested to hear more about how to set that up. I suspect custom domains of user1.website.com requires advanced backend skills and complex database setup?

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    Hey @taun2160 , in Payload Cloud, you receive

    my-app-name.payloadcms.app

    by default. A custom domain would be if you want to use your own apex or subdomain for that URL ie.

    special-app.mydomain.com

    . This can be added in Settings -> Custom Domains.

  • default discord avatar
    taun2160
    3 months ago

    Thanks Elliot. Can I use hooks to sign up the user and auto-generate a custom URL for them, that serves as their 'website' eg. user1.website.com ? Is this an incredibly complex project requiring extensive backend knowledge and scripts for manipulating the database, or can I use Payload API and pretty much what's mentioned in the docs? Is there more info on pricing for SAAS apps like this? For example, I'm curious how much it will cost for 50-100 users/custom-domains.

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    The creation of custom domains

    via API

    is not available as a feature, currently. I believe this is what you're describing.



    It's unclear to me if you're referring to a domain accessing your cloud project's API or if you're referring to spinning up multiple front-ends to access the same API

  • default discord avatar
    taun2160
    3 months ago

    I'm not entirely sure what I want as I don't yet have the knowledge at this stage - trying to get an idea of the variables involved.



    I'd like to offer portfolio websites for photographers. Instead of manually deploying every website, I'd like to somehow automate the process. I assume I should use 1 database with many databases within it for each user. When a user signs up I'd like them to receive their own domain eg www.user1.website.com, with their own admin panel wherein they can select the theme of their choice and CRUD their content.



    Do you have any suggestions to achieve this?



    @denolfe Ideally it's 1 front-end and 1 back-end and for the front-end each user has their own 'space' wherein they can choose their styling preferences - a lot like Myspace.



    It's fine if the website is rather www.website.com/user1, rather than creating custom domains of user1.website.com .



    Can you share any insight for either, probably wiser to go with website.com/user1.



    I basically want to have that and avoid deployment, so just 1 server for 'x' amount of users until it needs to scale. I know nothing about deployment.

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    I see. I think I follow what you're after. So you have 2 options here:



    1. Have one Payload deployment for the backend, but configure strict access control to make it so each user will only see their own stuff. An example of achieving this can be seen here with this plugin:

    https://github.com/joas8211/payload-tenancy

    Pros: One codebase. One deployment.


    Cons: If wanting to give them admin panel access, everyone would go to the same

    /admin

    url. No admin theming per client, this is done globally currently. Hard to make backups for just one client. Custom functionality per-client could be difficult via hooks, etc.



    2. Have multiple deployments

    but use shared code components

    . This allows you to deploy and maintain them separately but abstract out commonly-used patterns/components.



    Pros: Easy to customize on a per-client basis like custom admin components, hooks, etc. Can have dedicated domain and admin panel styling. Easy to do backups and version control.


    Cons: Separate codebases may get hard to maintain if you add a lot of customizations. Separate deployments ($).



    Really it all matters if you're wanting to offer a SaaS-type model with a hands-off/self-service approach, or if these are clients you'll be dealing with individually and will want to customize a lot of things. Hope this helps 👍

  • default discord avatar
    taun2160
    3 months ago

    Thanks a lot Elliot. I'm wondering about a hands-off SaaS model.


    Within that admin panel, users can select their own front-end theme for their 'space'?



    How is each user allocated their own 'space' - choosing their theme, CRUDing content and how does the URL creation work for each user?


    User signs up and is automatically assigned www.website.com/user1 and for the URL extends for their projects, www.website.com/user1/project1 ?



    Domains:
    abc.localhost.com:3000
    Users:
    admin@abc.com with role admin and password test
    user@abc.com with role user and password test
    Pages:
    ABC Home with content Hello, ABC!
    BBC
    Domains:
    bbc.localhost.com:3000
    Users:
    admin@bbc.com with role admin and password test
    user@bbc.com with role user and password test
    Pages:
    BBC Home with content Hello, BBC!


    So this creates a URL user1.website.com ?



    What are the pros and cons are taking that route? Is there a Payload pricing strategy based on the number of users?



    Is there no price increase if the model is rather www.website.com/user1 ?



    If there is a pricing strategy, where can we learn more about the details?

  • discord user avatar
    denolfe
    Payload Team
    3 months ago
    Within that admin panel, users can select their own front-end theme for their 'space'?

    This is only supported on a

    per Payload instance basis

    , currently.

    https://payloadcms.com/docs/admin/customizing-css#customizing-css-and-scss

    How is each user allocated their own 'space'?

    This would all be handled using access control. You would need to have some sort of attribute associated with the user like team, domain, etc. This would then be references in all of your access control functions to return a query constraint limiting them to see their own documents, not others.

    https://payloadcms.com/docs/access-control/overview#access-control

    So this creates a URL user1.website.com ?

    Like I mentioned before, creating custom domains is a manual process from the Payload Cloud project panel - not supported via API at this point.



    Is there a Payload pricing strategy based on the number of users?

    No, Payload does not base pricing based upon admin panel users.



    Is there no price increase if the model is rather www.website.com/user1 ?

    This would be managed completely by your domain and Payload application. No pricing changes.



    If there is a pricing strategy, where can we learn more about the details?

    It sounds like your custom needs would likely fall into our Enterprise Plan offering. If you'd like to know more, you can fill this form out, and we can get a better idea of your needs:

    https://payloadcms.com/for-enterprise
  • default discord avatar
    taun2160
    3 months ago

    Thanks @denolfe . With regards to my other Q -


    "User signs up and is automatically assigned www.website.com/user1 and for the URL extends for their projects, www.website.com/user1/project1 ?"



    So a user signs up and is assigned to a collection, such as Users, and therefore their CRUDing is assigned to them. How are they automatically assigned a URL for their front-end- www.website.com/user1/project4 ?



    (When I say their front-end, I mean the front-end of the singular SaaS app that displays tenants via their URL slug name, such as www.website.com/user4). In my prev post I mentioned they choose a theme for their space, meaning their front-end space, not the Payload admin panel. So www.website.com/user5 may look entirely different to www.website.com/user2 .)

  • discord user avatar
    denolfe
    Payload Team
    3 months ago

    In this case, you would likely create a

    domain

    property on the User collection to assign it to.



    I'm a little lost on how Payload Cloud is in this mix now, though.



    This seems like a conversation around how you'd orchestrate your programmatic functionality, now.

  • default discord avatar
    taun2160
    3 months ago

    Thanks. Payload Cloud pricing mentions "Up to 3 custom domains", which sparked the question of the pricing, limitations and opportunities of using Payload Cloud for multi-tenancy over others.

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.