面向Saas产品客户的自定义域功能 [英] Custom domain feature for saas product customers

查看:203
本文介绍了面向Saas产品客户的自定义域功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经构建了与golang rest api集成的angular 4的saas产品,并在AWS ec2实例上上传了构建.我的项目是一个基于多租户的应用程序,该程序将客户仪表板加载到商人名称.mystore.com子域上,但是一些要求自定义域功能的客户应该能够将其加载到mydomain.com上.

I have build a saas product with angular 4 integrated with golang rest api and uploaded the build on aws ec2 instance. My project is a multi-tenant based app which loads customers dashboard on merchant-name.mystore.com subdomain but some of the customers asking for custom domain feature like they should be able to load the app on mydomain.com .

我在apache2.conf文件中使用以下代码完成了子域部分,因此所有子域都从角度应用文件所在的apps文件夹中加载

I have done the the subdomain part with following code in apache2.conf file so all subdomain loads from apps folder where the angular app files located

<VirtualHost *:80>
    ServerAlias *.mystore.com
   DocumentRoot /var/www/html/apps
    <Directory "/var/www/html/apps">
        AllowOverride All
        Require all Granted
    </Directory>
</VirtualHost>

对于自定义域功能,我在admin中有一节可以保存自定义域,但不确定如何实现.

For custom domain feature I have a section in admin to save custom domain but not sure how should I implement it.

我考虑过的可能方法

  1. 创建虚拟主机文件,并在每个商户注册时使用其自定义域对其进行更新
  2. 以某种方式使用htaccess文件和mod_rewrite

Shopify可以这样做,但是不确定他们如何加载特定于商家的商店.另一点让我忙于思考,我应该要求更新哪些值

Shopify do it but not sure how they load merchant specific store. Another point kept me busy thinking about is what values should I ask to update

  1. 域名注册商的IP地址
  2. 名称服务器(不确定它将在aws上使用什么名称)
  3. 请按照文章的建议创建CNAME或A记录

推荐答案

我在我开发和管理的许多SaaS平台上都有类似的设置.正如您的客户所建议的,这种类型的设置当然是理想的.您应该计划从一开始就在其自己的域中为每个客户站点提供服务,可能还使用* SSL.我认为,对于当今架构良好的Saas服务来说,这是最佳做法.

I have a similar setup on a number of SaaS platforms I develop and manage. This type of setup is certainly desirable, as your clients suggest. You should plan to serve each customer site on its own domain, probably also with *SSL, from the begining. In my opinion, this is best practice for a well architected Saas service today.

在阅读您的问题时,我认为您已经对它进行了一些设计.

In reading your question, I think you are over engineering it a little.

对于同一服务器上的自定义域Saas应用,只需打开端口80即可所有流量不考虑域名.将所有客户域指向app.mystore.com,这是您的应用端点的CNAME.

For a custom domain Saas app on the same server, you simply open port 80 to all traffic, regardless of domain name. Point all customer domains to app.mystore.com, which is a CNAME to your app endpoint.

然后,该应用读取HTTP请求标头,并以此方式确定所请求的主机名.

The app then reads the HTTP request header, and in that way determines the host name that was requested.

最后,应用程序在其客户端数据库中查找主机名,并找到给定客户域的客户端记录.

Finally the app looks up the host name in its client database, and locates the client record for the give customer domain.

例如,在Nxinx中,您只需要:

For example, in Nxinx all you need is:

server {
    listen       80 default_server;
    server_name  _;
    root         /var/www/myservice/htdocs;
}

此服务器配置为指向此终结点的任何域提供全部捕获.

This server configuration provides a catch all for any domain that points to this endpoint.

这是Web服务器应允许其回答任何客户域的所有操作.该应用程序必须完成其余的工作.

That is all the web server should need to allow it to answer to any customer domain. The app must do the rest.

* 当您在此域上的应用程序上提供自定义域时,应计划为该域提供SSL终结点,例如

* When you serve a custom domain on an app on this domain, you should plan to serve the SSL endpoint for the domain, eg https://www.mycustomdomain.com. Consider this in your architecture design. Consider also the DNS issues also if your app fails over to a new IP.

这篇关于面向Saas产品客户的自定义域功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆