如何在 heroku 上为应用程序创建子域:(例如 sub.myapp.herokuapp.com) [英] How to create a subsubdomain for an app on heroku: (e.g. sub.myapp.herokuapp.com)
问题描述
我正在运行一个多租户应用程序,它在 Heroku 上为租户使用子域.在生产中,我有一个域,其中子域指向我的 heroku 应用程序.(这一切正常)
I am running a multi tenant app that uses subdomains for tenants on Heroku. In production I have a domain where subdomains point to my heroku app. (This all works fine)
对于暂存,我想在不创建另一个域的情况下进行测试.由于我的应用程序使用它看到的第一个子域来查找当前租户,因此我希望使用如下网址:tenant.myapp.herokuapp.com.但是,这不起作用(heroku 返回没有此类应用程序"错误.)
For staging, I'd like to test without creating another domain. Since my app uses the first subdomain it sees to find the current tenant, I was hoping to use a url like: tenant.myapp.herokuapp.com. However, this is not working (heroku returns a 'no such app' error.)
我发现 2 年前的这篇文章 说这应该是可能的,但是我在参考文档中不再看到此附加组件/选项.
I've found this post from 2 years ago that says it should be possible, but I don't see this add-on/option anymore in the referenced documentation.
我尝试通过运行
heroku 域:添加 *.myapp.herokuapp.com
但这返回了
<代码>!试图劫持另一个 Heroku 应用程序?啧啧啧.
有谁知道这是否仍然可以实现,如果可以,如何实现?
Does anyone know if this can still be accomplished and if so, how?
注意:我目前正在通过 CNAMING *.staging.myapp.com 到 myapp.heroku.com 使用我的暂存环境,但想要清理它.
note: I'm currently using my staging environment by CNAMING *.staging.myapp.com to myapp.heroku.com, but would like to clean that up.
推荐答案
这里是如何在 heroku 中使用子域
Here's how you use subdomains with heroku
对于要附加到应用程序的每个自定义子域(例如 www.example.com),请使用 Heroku 中的 domains:add
命令命令行:
Custom subdomains
For each custom subdomain you want to attach to your app (for example, www.example.com), use the
domains:add
command from the Heroku CLI:
$ heroku domains:add www.example.com`
Adding www.example.com to example... done
<小时>
这不再有效:子域目前在heroku上不可能"
This is no longer valid: "Subdomains are currently not possible on heroku"
这篇关于如何在 heroku 上为应用程序创建子域:(例如 sub.myapp.herokuapp.com)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!