如何创建 SaaS 应用程序?

发布于 2024-07-24 20:34:58 字数 640 浏览 3 评论 0原文

我不知道还能怎么说,所以我只是要解释我的理想场景,希望您能向我解释如何实现它...

我正在使用 Zend Framework 创建一个应用程序,该应用程序将托管于梦想主机。 该应用程序将托管在其自己的域上(即 example-app.com)。 基本上,用户应该能够注册,获取自己的域 exampleuser.example-app.com 或 example-app.com/sampleuser,它指向看起来像他们自己的应用程序实例的内容,这实际上是一个实例根据 url 提供不同的内容。

最终,我希望我的用户能够创建自己的域(例如 foobar.com),指向sampleuser.example-app.com,这样 foobar.com 的访问者就不会注意到该网站确实正在提供服务来自 example-app.com。

我不知道如何做大部分事情。 这个过程是如何进行的? 我是否需要使用 Apache 做一些时髦的事情,或者可以使用第三方主机(例如 DreamHost)来完成吗?

更新:感谢您的建议! 我决定硬着头皮升级我的托管计划以利用通配符子域。 它比我预期的便宜! 我还发现了一些域名经销商计划,例如 opensrs.com,它们有自己的 API。 我认为使用这些 API 之一将可以解决我的域名注册问题。

I don't know how else to say it so I'm just going to explain my ideal scenario and hopefully you can explain to me how to implement it...

I'm creating an application with the Zend Framework that will be hosted with DreamHost. The application will be hosted on its own domain (i.e. example-app.com). Basically, a user should be able to sign up, get their own domain sampleuser.example-app.com or example-app.com/sampleuser which points to, what looks like their own instance of the app, which is really a single instance serving up different content based on the url.

Eventually, I want my users to be able to create their own domain (like foobar.com) that points to sampleuser.example-app.com, such that visitors to foobar.com don't notice that the site is really being served up from example-app.com.

I don't know how to do most of that stuff. How does this process work? Do I need to do some funky stuff with Apache or can this be done with a third party host, like DreamHost?

Update: Thanks for the advice! I've decided to bite the bullet and upgrade my hosting plan to utilize wildcard subdomains. It's cheaper than I was expecting! I also found out about domain reseller programs, like opensrs.com, that have their own API. I think using one of these APIs will be the solution to my domain registration issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柠栀 2024-07-31 20:34:58

子域很容易。 在托管环境中,大多数情况下,apache 配置为捕获主域下面的所有子域调用。 您只需要定义一个通配符 DNS,这样 *.example-app.com 就会指向您服务器的 IP。 然后您的网站应该捕获对这些子域名的所有调用。

其他领域很难。 它们需要在 Apache 中配置为虚拟主机 - 请参阅 http://httpd .apache.org/docs/1.3/vhosts/name-based.html - 这意味着很难实现自动化,特别是在托管环境中 - 除非你的主机给你一些 API 来做到这一点(简单且更可行的方案是为您的网站分配一个独特的 IP,然后您可以使用 Apache 捕获所有内容 - 可以使用您的托管控制面板进行配置或开箱即用 - 然后只需将 DNS 服务器指向您的 IP )。

然后,在将 Apache 配置为将所有必要的调用指向您的网站后,您可以通过以下方式区分每个子域的应用程序分区:

  • 从 HTTP 请求获取主机标头
  • 有一个包含您正在服务的所有子域名的数据库表
  • 进行查找到该数据库表来确定实例或用户 ID,并在稍后使用它来过滤数据/或选择数据库(如果您要使用“每个应用程序实例的数据库”模式)。

祝你好运 :)

Subdomains are easy. In hosting environements, in most cases, apache is configured to catch all subdomain calls below the main domain. You just need to have a wildcard DNS defined, so *.example-app.com are pointed to IP of your server. Then your website should catch all calls to those subdomain names.

Other domains are hard. They need to be configured as virtual hosts in Apache - see http://httpd.apache.org/docs/1.3/vhosts/name-based.html - that means it will be difficult to automate that, especially in hosting environement - unless your host gives you some API to do just that (easy and more feasible scenario would be to have a distinctive IP assigned to your website, then you can catch all with your Apache - it's probably possible to configure using your hosting control panel or works out of the box - and then just point DNS servers to your IP).

Then, after you have configured your Apache to point all necessary calls to your website, you can differnetiate application partitions per subdomain in this way:

  • get the host header from HTTP request
  • have a database table containing all subdomain names you're serving
  • make a lookup to that database table to determine instance, or user, id and use it later for filtering data / or selecting a database, if you'll go with a "database per application instance" schema.

Good luck :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文