如何为 saas 软件提供 cname 转发支持 [英] How to give cname forward support to saas software

查看:22
本文介绍了如何为 saas 软件提供 cname 转发支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 web 应用程序,用户可以在其中创建他们的帐户并使用该服务.现在我想给他们一个自定义域工具app.customer1web.com points_to myservice.com with userid customer1一旦他设置了自定义域,对于世界来说,我的服务似乎正在他的机器上运行.博客、wp.com、tumblr 等许多服务提供这个功能.

I have a webapp where users can create their account and use the service. Now I want to give them a custom domain facility where app.customer1web.com points_to myservice.com with userid customer1 once he sets up the custom domain, for the world it looks like my service is running on his machine. Many services like blogger, wp.com, tumblr give this feature.

我该怎么做?我正在使用 java 编写我的网络应用程序.请求进来时如何将域名映射到用户 ID?

how do i do that? I am using java to write my web app. How do i map domain name to userid when request comes in?

推荐答案

请求进来时如何将域名映射到用户名?

How do i map domain name to userid when request comes in?

显然,您必须将该信息存储在某个地方,很可能是在数据库中.

Obviously, you'll have to store that information somewhere, most likely in a database.

  1. 添加一个带有列的数据库表domains:

  • 客户 ID
  • 姓名
  • 活动(1 或 NULL)
  • 挑战

为 (name, active) 添加唯一键以确保域名仅映射一次.

Add unique key for (name, active) to ensure a domain name is mapped only once.

当客户尝试添加域时,添加一行 active=NULL 并将挑战设置为随机字符串.

When a customer attempts to add a domain, add a row with active=NULL and challenge set to a random string.

向客户显示随机字符串,并要求他们在网站上放置一个包含它的网页,或者使用它创建一个虚拟 DNS 记录以验证域所有权(Google Apps 就是这样做的).

Show the random string to the customer and ask them to put up a web page with it on the site or create a dummy DNS record with it to verify domain ownership (this is how Google Apps do it).

您可以通过向管理联系人发送电子邮件或其他方式来验证所有权.

You could verify ownership by sending an email to the administrative contact or in some other way.

当客户说他做了你在第 2 步中指示他们做的事情时,验证它并设置 active=1,challenge=NULL.

When the customer says he did what you instructed them to do in step #2, verify it and set active=1, challenge=NULL.

如果该域之前对其他客户有效,请删除这些记录或设置 active=0.

If the domain was previously active for some other customer, delete those records or set active=0.

要求客户为其域添加 CNAME 记录并将其转发到您的域,例如hosted.myservice.com(Google 将 ghs.google.com 用于 Google Apps).

Ask the customer to add a CNAME record for their domain and forward it to your domain, e.g. hosted.myservice.com (Google uses ghs.google.com for Google Apps).

当有请求进来时,做

SELECT customerId FROM domains WHERE name=:requestDomain AND active=1

更好的方法可能是自动为您的客户提供 .myservice.com 格式的域,除了自定义域.这给您带来两个好处:

A better way may be to automatically offer your customers a domain in the format of <customername>.myservice.com, in addition to custom domains. This gives you two benefits:

  • 不想使用自己域名的客户仍然可以自定义他们的登录页面,例如带有公司徽标.

  • Customers who don't wan't to use their own domain can still customize their login page, e.g. with a company logo.

对于自定义域,您可以要求您的客户将它们转发到 .myservice.com 而不是通用的 hosted.myservice.com>.

For custom domains, you can ask your customer to forward them to <customername>.myservice.com instead of to a generic hosted.myservice.com.

这使您能够在多台服务器之间水平划分客户,而无需要求客户对其进行任何更改.例如,您可以让客户选择他们希望在欧盟还是美国托管他们的帐户.当他们更改时,只需传输他们的数据并更新 .myservice.com.他们的自定义域将自动运行.

This enables you to horizontally partition customers among multiple servers without having to ask customers to change anything on their end. For example, you could give customers an option to choose whether they want their account hosted in EU or US. When they change it, just transfer their data and update <customername>.myservice.com. Their custom domain will work automatically.

为此,您必须为 *.myservice.com 设置通配符 DNS 记录(除非您还需要后一个功能,在这种情况下,您必须管理单个记录).

To do this, you'd have to set up a wildcard DNS record for *.myservice.com (unless you also need the latter feature, in which case you'll have to manage individual records).

这篇关于如何为 saas 软件提供 cname 转发支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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