I currently give the ability for my users to have a subdomain for their account so:
subdomain.myaddress.com
will point to the users profile. I want to be able to give the user the ability to point their own domains as well so that both will work and point to the user profile.
How to do that?
Also, if you happen to know about Heroku. There is a plugin to enable custom domains but I have to call: heroku domains:add *.yourdomain.com (or use GUI)
Is there a way to make my app call that command instead?
Your application will need to listen to whatever domain the user enters, therefore you would have to use the heroku gem inside your application to add the custom domain the user enters to your application.
Using subdomains is obviously the simpler option here as you can just have the wildcard domain setup on your domain *.mydomain.com and let the choose whatever subdomain they want and then have your application work out the account to use from the subdomain.
You can use DNS CNAME records to alias one domain name to another. There are restrictions: you can't use a CNAME on a top-level domain (subdomains only). I don't know about automating it, but CNAME's are commonly used on heroku.
Related
I have registered 2 websites (say source.com and target.info) but only one (target.info) is hosted. I could redirect source.com to hosted target.info/source but I would like to display source.com in the address bar rather than the physical URL target.info/source or subdomain source.target.info. Is this possible, knowing that I don’t have a .htaccess for source.com since it is not hosted?
I tried to redirect source.com to target.info/source on my registrar account but then I get target.info/source in the address bar. Ideally I would like to have source.com concatenated with the file names, but source.com alone would be fine.
An alias domain might be close to what you are looking for but you may find it called something different if you use a different hosting provider. You will however, still need to point the domain to your hosting provider (in the case of hosting providers using cPanel whose documentation I have linked this would involve changing the nameservers at your registrar).
Form the docs:
Domain aliases are domains that you own, but which do not contain any content. Instead, they point to the contents of another domain or subdomain on your account. This is useful, for example, to hold a domain that you will later sell, or to redirect traffic to another domain.
I am trying to use rails app as an extension of my Weebly app.
current domain is hosted by Weebly. I am trying to the following,
I am trying to use the one domain for two different applications(Weebly template website and Rails application)
I thought of two solutions and I don't know if any of them are applicable.
solution
add a subdomain eg. welcomerailsapp.example.com
or
www.example.com/welcomerailsapp
I will be pushing my Rails app to the Heroku server
little guidance would be appreciated
thank you
You can use a CNAME record to do what you want. This would be done at your domain registrar or DNS provider.
Example:
Domain: mydomain.com
CNAME www => yourweeblyhost.com (Weebly app server)
CNAME rails => yourrailsapp.com (Heroku server)
www.mydomain.com would then route to your Weebly app, rails.mydomain.com would route to your Rails app.
This can be done on Weebly via the settings tab under your domain. So all you'd need to do is pick a name for your subdomain, with that as the "name" for the CNAME record and point it to the URL Heroku gives you for your Rails app.
You can also get more complex with it by using wildcards.
So if you only wanted one subdomain (www), for example, to route to the Weebly app; you can configure it as such by creating a CNAME for the www subdomain and pointing it to Weebly as noted above. Then, by using a wildcard (usually * on most providers) as the "name" you can tell the internet that [anyotherthing].mydomain.com should route to the Rails app without having to define each subdomain manually.
I want to redirect myapp.herokuapp.com to mydomain.com.
What I was able to achieve with company that I bought a domain from (lets call them X) is to add new CNAME, so a www.mydomain.com displays myapp.herokuapp.com and that is OK.
What I also want to do is to be able to access the app without the need to write www before the rest of the address. It was said to me that I should change A record within domain configuration, but X company does not allow it. What I can (and what they recommended) is to set and option in domain configuration called IP/URL/host redirect to myapp.herokuapp.com.
Changing this makes my website available under the mydomain.com without the need to write www before, but what it also does is it displays the website in a frame.
What should I do to achieve this? Is this a heroku thing, the X company thing or should I change something in the way my website can be displayed?
Typing www.mydomain.com displays the website correctly - without the <frameset><frame></frame></frameset> tags.
In the Heroku Dashboard "Domains and Certificate" section, add to your custom domains both domain names, "www.mydomain.com" and "mydomain.com".
Make your DNS target the "mydomain.herokuapp.com" in both records.
Check https://devcenter.heroku.com/articles/custom-domains for more information.
I'm looking to set up custom domains for users. Much like Tumblr does.
I understand that the user must point their A record to an IP address. I found some information here: Custom domains in a Rails App
Can someone give me an example of this with a Heroku/Rails 3 setup? Is it even possible?
If you setup a wildcard DNS to point to your main app, you can use the :subdomain in config/routes.rb to handle your business logic.
We have a Rails 3 app which allows users to create a profile and access it with a subdomain. So for example:
user1.app.com
user2.app.com
user3.app.com
Now, suppose they wanted to point their own domain name to their profile, so www.user1.com shows user1.app.com, and www.user1.com/my-content/ shows user1.app.com/my-content/. Is it possible for them to simply change their nameservers to point to us, and we handle the routing? I'm afraid it would be a deal breaker if the user had to do any DNS configuration beyond just changing their nameservers.
Thanks!
This is really two questions.
So I guess I'll answer it like that.
How can I allow customers to add a custom domain to my heroku-based app?
So, in your example, their domain name is www.user1.com
Two things need to happen
www.user1.com needs to be added to your heroku domains for the app
the dns for www.user1.com needs to be set to the heroku servers
In order to add this new domain, I guess you need to store the custom domain in the app,
and when it is changed, or created, ensure a queued task is setup to push this config change to heroku.
In order to do the dns correctly, I hope it is enough that they add a CNAME for user1.app.com.
Therefore, if you have a wildcard CNAME linking to heroku's dns, you can avoid the type of downtime that can occur if Heroku gets DOS-ed again.
How can I show content based on domain, rather than just subdomain?
Well, somehow you already differentiate user1.app.com from user2.app.com
Maybe you just sniffed request.host.
Now you just have to try the custom domain first.
Maybe this'll work.
before_filter :set_client
def set_client
#client = Client.find_by_custom_domain(request.host) || Client.find_by_subdomain(request.host.split(".").first)
unless #client
raise "unrecognised domain #{request.host}"
end
end
You need to get them first of all have them set www.user1.com to point to proxy.heroku.com (or setup your own cname entry to proxy.heroku.com and get them to cname their domains to that) and then you need to register their custom domain with your heroku app so the correct application responds at Heroku stored against their account?? in your application so it can be matched on incoming requests.
This technique is employed in the Locomotive Rails CMS so I'd suggest looking at that - it uses the Heroku gem INSIDE the application so custom domains can be added via the site administrator which in turn talks to the Heroku API to add the custom domain to the application.