简体   繁体   English

在Rails 4中本地工作但在生产中不工作的子域(使用Heroku和Godaddy)

[英]Subdomains working locally in Rails 4, but not in production (using Heroku and Godaddy)

My rails app uses subdomains to handle requests from different user roles. 我的Rails应用程序使用子域来处理来自不同用户角色的请求。 The app has two user roles, Role1 and Role2. 该应用程序具有两个用户角色,Role1和Role2。 I've been using vcap.me:3000 to test this locally. 我一直在使用vcap.me:3000在本地进行测试。 For example: the request "role1.vcap.me:3000" is processed differently than "role2.vcap.me:3000" because I want Role1 users to see a page that's different to that of Role2 users. 例如:请求“ role1.vcap.me:3000”与“ role2.vcap.me:3000”的处理方式不同,因为我希望Role1用户看到的页面与Role2用户的页面不同。 The above mentioned works perfectly locally. 上面提到的在本地完美运行。

My problem is that in production, this is not working: I purchased a domain from GoDaddy (example: domain.com) and I'm deploying to Heroku (example: myapp.herokuapp.com) 我的问题是,在生产中,此方法不起作用:我从GoDaddy(例如:domain.com)购买了一个域,然后将其部署到了Heroku(例如:myapp.herokuapp.com)

I was able to point www.domain.com to myapp.herokuapp.com in GoDaddy by adding a CNAME record that points 'www' to myapp.herokuapp.com. 通过添加将“ www”指向myapp.herokuapp.com的CNAME记录,我能够在GoDaddy中将www.domain.com指向myapp.herokuapp.com。 So if I send a request to www.domain.com, I'm directed to my app. 因此,如果我向www.domain.com发送请求,则会定向到我的应用程序。 However, I have not been able to make the subdomains work. 但是,我无法使子域正常工作。 Example: this request role1.domain.com does not direct me to my app. 示例:此请求role1.domain.com不会将我定向到我的应用程序。

I followed Heroku's docs on Custom Domain Names for Apps and I tried to find answers in stackoverflow and other sites (links below) that would help me figure out my problem but I couldn't get any of their solutions to work. 我关注了Heroku关于应用程序自定义域名的文档,并尝试在stackoverflow和其他站点(下面的链接)中找到答案,这可以帮助我解决我的问题,但我无法获得他们的任何解决方案。

https://stackoverflow.com/questions/33086225/heroku-godaddy-ssl-wildcard-setup https://stackoverflow.com/questions/33086225/heroku-godaddy-ssl-wildcard-setup

Rails, Heroku and Subdomains. Rails,Heroku和子域。 Is my special case scenario feasible? 我的特殊情况是否可行?

https://forum.upcase.com/t/subdomain-not-working-in-heroku-and-namecheap/5096 https://forum.upcase.com/t/subdomain-not-working-in-heroku-and-namecheap/5096

Some posts are suggesting that I need to use something like DNSimple (which I never used before). 一些帖子建议我需要使用DNSimple之类的东西(以前从未使用过)。 Do I need to use a service like DNSimple? 我需要使用DNSimple之类的服务吗? How should I set things up in that case? 在这种情况下,我应该如何设置? Or, can I set things up properly just with GoDaddy? 或者,是否可以仅通过GoDaddy正确设置? What should I do in that case? 在这种情况下我该怎么办?

Any guidance would be greatly appreciated since I have little experience with DNS. 因为我对DNS的经验很少,所以任何指导都将不胜感激。 Thanks in advance! 提前致谢!

I was able to solve my problem! 我能够解决我的问题! I didn't have to use a service like DNSimple and could make it work just through GoDaddy. 我不必使用像DNSimple这样的服务,就可以通过GoDaddy使其工作。 I added a CNAME record *.domain.com that points to myapp.herokuapp.com and added the domain *.domain.com in heroku by doing: heroku domains:add *.domain.com 我添加了一个指向myapp.herokuapp.com的CNAME记录* .domain.com,并通过执行以下操作在heroku中添加了域* .domain.com:heroku domains:add * .domain.com

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

相关问题 Rails 4 - javascript文件未在生产中加载但在本地运行良好。 (Heroku的) - Rails 4 - javascript files not loading in production but working well locally. (Heroku) Rails,Heroku,Cloudinary:虽然在本地工作,但照片在生产中未上传到 cloudinary - Rails, Heroku, Cloudinary: Photos not uploading to cloudinary in production, although working locally JavaScript无法在本地和Heroku上进行生产 - JavaScript not working on Production locally and heroku Mailform 在本地工作但不在生产中(Heroku、Rails) - Mailform works locally but not in production (Heroku, Rails) Rails 应用程序在本地工作,但不适用于 Heroku 的生产环境 - Rails App works locally, but not in production with Heroku Rails应用程序在本地运行,但不能在Heroku上运行 - Rails app working locally but not on Heroku 表单在本地工作,而不是在heroku中工作? 导轨3 - Form working locally, and not in heroku? Rails 3 编译 Rails / ReactJS 不在生产环境(heroku)中工作,但在本地工作。 CSSSyntaxError: MissedSemicolon - Compiling Rails / ReactJS not working in production (heroku), but working locally. CSSSyntaxError : MissedSemicolon Rails应用程序无法在Heroku生产中使用 - Rails App Not Working In Heroku Production 在Heroku Rails 4上无法生产的类别 - Categories not working in production at heroku Rails 4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM