简体   繁体   English

创建一个子域以使用PHP启用CNAME记录

[英]Create a sub domain to enable a CNAME Record with PHP

I am building a Saas Application . 我正在构建一个Saas应用程序

In it, there are multiple user accounts, who will be accessing the application from their own domains. 其中有多个用户帐户,这些用户帐户将从他们自己的域访问该应用程序。

They will link their domains to my root domain where the application is installed, using CNAME records. 他们将使用CNAME记录将其域链接到安装该应用程序的我的根域。

When a user registers, they are asked to enter their domain name. 用户注册时,要求他们输入其域名。 We need to create a new Alias for enabling the CNAME Record programmatically using PHP . 我们需要创建一个新的Alias,以便使用PHP通过编程方式启用CNAME记录。

Is there any way to do it? 有什么办法吗?

Edit 编辑

Each client of the application needs to access the application via their domains (a custom domain that client owns) which are pointed to our domain (the base domain of the application)using CNAME record in their DNS records. 应用程序的每个客户端都需要使用其DNS记录中的CNAME记录通过其域(客户端拥有的自定义域)访问我们的域(应用程序的基本域)。

How can I programmatically bind the custom domain supplied by the client with my hosting account from PHP? 如何以编程方式将客户端提供的自定义域与我的PHP托管帐户绑定? Say adding of Parked domain or Domain Alias from PHP code. 比如说从PHP代码添加Parked域或Domain Alias。

Yes, but how you do it depends on your DNS server - and you told us nothing about that. 是的,但是您的操作方式取决于您的DNS服务器-您对此一无所获。 With Bind (for example) it's just a matter of updating the zone files and reloading the config. 例如,使用Bind,只需更新区域文件并重新加载配置即可。 With Active Directory, an LDIF call. 通过Active Directory,可以进行LDIF调用。 However what you propose is completely unworkable in practice and also unnecessary. 但是,您提出的建议在实践中是完全不可行的,也是不必要的。

You cannot start serving DNS for a zone you don't already control. 您无法开始为尚未控制的区域提供DNS服务。

Nobody in their right mind is going to open up their DNS to give you programmatic access. 在他们的头脑中没有人会开放他们的DNS来为您提供程序化访问。

I also said its unnecessary - all the DNS does is point traffic to your service. 我还说这是不必要的-DNS所做的只是将流量指向您的服务。 So it doesn't matter if you configure the DNS or someone else does. 因此,无论您配置DNS还是其他人都没有关系。 Each HTTP[S] request coming in bears the domain name - so your service can easily apply the relevant branding / billing / data multiplexing required. 每个传入的HTTP [S]请求都带有域名-因此您的服务可以轻松地应用所需的相关品牌/计费/数据多路复用。

Sorting out how you provision SSL certificates is a much more complicated problem than DNS. 整理如何配置SSL证书比DNS复杂得多。 Again the business of setting up the data and configuring it is trivial, but you need to prove to a third party (the certificate authority) that you are the legal entity described by the certificate (which you are not). 同样,设置数据和配置数据的工作微不足道,但是您需要向第三方(证书颁发机构)证明您是证书所描述的法人(不是)。

Hence your options are: 因此,您的选择是:

1) Get your client to configure the DNS CNAME pointing to your service name and provide you with the certificate 1)让您的客户端配置指向您的服务名称的DNS CNAME并向您提供证书

2) you provision a DNS CNAME and SSL certificate as ${client}.${yourdomain} 2)您将DNS CNAME和SSL证书设置为$ {client}。$ {yourdomain}

3) ask your clients to proxy the request 3)请求您的客户代理请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM