如何轻松切换开发环境和生产环境
让开发和测试浏览器将我们的生产域名解析为开发和测试环境的最佳方法是什么?假设我们的生产域是 widgets.com。过去,我们对 devwidgets.com、testwidgets.com、demowidgets.com 等使用内部 DNS。但这被证明是一个很大的痛苦。似乎最好有一个主机文件或代理服务器设置,以便每个客户端都可以选择将 widgets.com 解析到每个预生产环境。有想法吗?其他人是如何解决这个问题的?
What is the best way to get dev and test browsers to resolve our production domain name to dev and test environments? Say our production domain is widgets.com. In the past, we've used internal DNS for devwidgets.com, testwidgets.com, demowidgets.com, etc. But this is proving to be big pain. Seems better to have a host file or proxy server setup so each client can choose to resolve widgets.com to each pre-prod environment. Ideas? How have others solved this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在不同的端口(对于内部和外部设置来说最简单)或在不同的 cname(对于外部设置)上运行不同的版本:
这意味着可以通过 Web 服务器集中配置不同的环境,而不必管理大量不同的主机文件。
You can run different versions on different ports (easiest for internal and external setup) or on different cnames (for external setup):
This means that the different environments can be configured centrally through the web server rather than having to manage lots of different host files.
正如您所说,我们已经通过使用内部 dns 解决了这个问题。每个开发人员都有自己的环境,所以我可以转到www.ordomain.com.branch2.environment10,其中environment10是我的特定环境,而branch2指的是特定的签出,以防我因为正在处理不同的项目而获得多个签出同时。只是不同的环境可能就足够你了。
在另一种情况下,我配置了不同的 cname,使用 dev.widgets.com 远程访问我的开发环境。缺点是任何人都可以访问它,因此您应该对其进行密码保护,或使用 IP 过滤器。
我不推荐使用主机文件。这很难维护,并且您无法从开发计算机访问实时环境。
We have solved it by using internal dns, like you said. Each developer has his own environment, so I can goto www.ordomain.com.branch2.environment10, where environment10 is my specific environment, and branch2 refers to a specific checkout, in case I got multiple checkouts because I'm working on different projects simultaniously. Just the different environment may suffice for you.
In another situation I've configured a different cname, using dev.widgets.com for remotely getting to my development environment. Disadvantage is that anyone can reach it, so you should password protect it, or use an IP filter.
I wouldn't recomment using hosts files. This is hard to maintain, and you can't reach the live environment from your development pc.