I can't figure out what I'm overlooking, perhaps it's obvious or lack of understanding.
The app I'm working with uses subdomains which on the hosting server work properly. I figured locally installing would kick up some issues around routing, so I read up on making changes to /etc/hosts and using the Ghost gem. Both seem to work fine i.e. localhost:3000/ becomes myapp.local:3000 but I don't understand how to go about logging into a subdomain account. Here's an example...
myapp.local:3000/session/new = the default login page for the app
myapp.local:3000/signup = default signup page
I can create an account here e.g. Sub1
The thank you page is shown w/ the reference to sub1.myapp.com which points to the hosted app (the local db shows this domain as well)
sub1.myapp.local manually added to /etc/hosts and dscacheutil -flushcache
sub1.myapp.local:3000/session/new is the subdomain
login attempts return that this isn't a valid domain. This seems to make sense because the local db shows the url as sub1.myapp.com on the hosting server.
So my question is whether there's a local workaround that I can use for development or have I totally missed a fundamental concept along the way?
you might just want to try putting the actual dot com in your /etc/hosts file.
ie:
127.0.0.1 sub1.myapp.com
127.0.0.1 myapp.com
127.0.0.1 anyothersubdomains.myapp.com
what this usually does is trick your computer into thinking it is the host of all of those, so you can't go to the real site anymore in a web browser.
if you do want it to be .local, presumably so that you can refer to the real online site while working on a local copy, you should probably take a look in app/controllers/application_controller.rb (sometimes application.rb) and look for logic in there that helps determine what to do depending on the subdomain. maybe its hard coded to only look for a .com or something.
If you are using the webrick server or something like Puma for development you can use lvh.me to access your subdomains. e.g.
http://sub.lvh.me:3000/
http://lvh.me:3000/ is equal http://localhost:3000/
Related
I developed two rails apps, they will each go on site.com and something.site.com respectively. In development mode they are run on localhost:3000 and localhost:4000, you must be logged into site.com to access something.site.com.
I have the cookies set up to handle domains from :all, and the tests all pass in relation to creating and destroying sessions. How ever I am unfamiliar how to test the cookies with out actually deploying the apps to production. I don't have staging servers, their small basic apps and I don't want them public. Is their any ways, on my mac, I can test (by launching both apps) the domain specific cookies?
You can edit your hosts file located at /etc/hosts to point 127.0.0.1 to local.site.com and then access your rails apps at local.site.com:3000 and local.site.com:4000
127.0.0.1 localhost local.site.com
I bet you could update your hosts file to point something.localhost to 127.0.0.1
127.0.0.1 something.localhost in `/etc/hosts
I'm sure you've read that as long as the TLD is the same, this should work.
Look at using POW and Powder. Runs slower, but allows you to run concurrent apps on localhost.
Pow User's Manual
I'm baffled by an issue with my site in IIS 7 - it works fine when it's the only site that's running, and no binding is being used. I have my domain name www.mysite.com registered with the DNS to point to my IP and it pulls up my site great. However, now I want to add a second site in IIS, so I have to start using the binding host names, but when I put www.mysite.com in as the host name, suddenly I can't pull up the site anymore! And, I don't know if this information is helpful, but if I start up the Default Web Site (that has no bindings) along side my current website that I've added the binding to, the domain name will pull the default web site (IIS7 jpeg) instead! It's like it completely doesn't see the binding I've added, other than the fact that it allows me to run both sites at the same time. It doesn't take time for the binding to take effect in IIS right? Waiting until tomorrow won't make a difference I imagine?
I've done this many times before on other servers, and as far as I can remember, I seem to be doing everything the same as before. I can't figure out why it's not working this time. Am I forgetting something crucial here?
The only difference I can tell is that this domain is hosted with Google, which requires me to update the DNS myself. All those other times, I've called up goDaddy and said, 'Hey, can you point this domain to this IP address?' and they do it for me. Is it possible that I've updated the DNS incorrectly, or incompletely? I don't know if that can be the case if the domain has been pulling up the website just fine all this time until I tried to add the second website on the server... Any ideas?
BTW, this is a virtual server (2008 R2) hosted at atlantic.net - I've never used them before. All the other virtual servers I've used have been with 1and1. Don't know if that makes a difference too.
Ok, I figured it out - turns out the DNS WAS set incorrectly after all! I was able to narrow down the issue when I started creating a bunch of dummy sites and playing with my local computer's hostfile and saw that everything seemed to be routing just fine. So, clearly IIS was working as expected. So, I then called GoDaddy repeatedly until I found someone who agreed to help me with a Google domain. Apparently, from what I could understand, I set the IP address in the wrong place which only made the domain forward as the IP address, so there was no hostname for IIS to match it to, which is why it pulled up the default website (no bindings) with no problems, and ONLY the default website! He directed me to another screen (the DNS Zone File tab) where I could set it properly. Now, everything goes to the expected sites!
Hopefully this will help another newbie out one day when they have to set their own DNS (gasp!)
Hello wonderful world of the stack!
This is my first deployment using Heroku (I am just using their free service at the moment).
I have set up my domain to point to Heroku and renamed my application and everything works fine. the one thing I would like to change however is the format of the final url.
For example, after typing in:
www.example.com
The page loads and the url changes to:
example.herokuapp.com
Is there any way that I can change this behaviour so that the url remains the same?
I have tried using the help pages supplied by Heroku and various searches (usually similar searches to this question title) but I am not sure if I am searching for the correct thing as I seem to only get unrelated results.
Thanks in advance for any light you may be able to shed on this matter
This sound like a problem with your DNS Domain setup rather than heroku. Read about how to configure your domains properly for heroku use here.
It sounds to me as if you are doing some kind of 'web redirection' (custom stuff that each hosting provider offers) with your domain, when you should set CNAME or A Records.
Which provider hosts your domain / where did you 'buy' it?
I have a client who wants to migrate his Rails app to Heroku. However the client also has a blog associated with his domain that runs on WordPress. Currently, the WordPress blog is running happily alongside the Rails app, but once we migrate to Heroku, that clearly won't be possible.
The url for the app is like http://mydomain.com, and the url for the blog is like http://mydomain/blog.
I realize that the best long-term solution is to redo the blog in a Rails format like Toto or Jekyll. But in the short term, what is the best way to continue hosting the WP blog where it is (or somewhere) but use Heroku to run the app? The client doesn't want the blog to be on a subdomain, but to remain at mydomain/blog for SEO reasons and also since there is traffic to the blog. I have two ideas:
Use rack_rewrite or refraction (or just a regular old 301 and Apache mod_rewrite) on the old (non-Heroku) server to redirect the main url from the old site to Heroku. In this case, I can just leave the Wordpress blog running happily where it is. I think?? Is there a reason to choose one of those options (rack_rewrite, refraction, or mod_rewrite) over the others if I do it this way?
Switch the DNS info to point to the Heroku site, and then use a 301 redirect from the blog to the old site. But then I'll have to get the old (non-Heroku) site on a subdomain and use some kind of rewrite rules anyway so it looks like it isn't a subdomain.
Are either of these approaches preferable, or is there another way to do it that's easier that I'm missing?
The only tenable long term/scalable solution would be to host the blog permanently on a sub-domain or different domain and add a redirect from mydomain.com/blog to the new location (ie: blog.mydomain.com).
You would need a single server running a front-end like Apache/nginx on mydomain.com to serve up mixed back-ends like Rails and Wordpress and that is not possible on Heroku.
Sadly, this is where you need to dig in as a consultant and be stern with your client about the technical limitations.
Why does you client want to migrate to Heroku? Is there a larger goal behind that you could accomplish with different hosting where you control the front-end and can mix in different back ends?
Another solution is to set heroku to http://app.example.com, and Wordpress to http://example.com. You put your Wordpress-landing page in the root , and blog on /blog. When the user click "login" or "signup" on the landing-page, they're linked to the heroku-app.
This will be optimal in a SEO-perspective, but require some DNS-knowledge.
Winfield's answer is not correct. You can run a reverse proxy on your rack server (via Heroku) to direct to the blog, wherever it may be.
See https://github.com/jaswope/rack-reverse-proxy
After you install the gem and set up your app according to the docs, your ./config.ru file will have something like this:
use Rack::ReverseProxy do
reverse_proxy(/^\/blog(\/.*)$/,
'http://<app-name>.herokuapp.com$1',
opts = {:preserve_host => true})
end
One of my rails apps (using passenger and apache) is changing server hosts. I've got the app running on both servers (the new one in testing) and the DNS TTL to 5 minutes. I've been told (and experienced something like this myself) by a colleague that sometimes DNS resolvers slightly ignore the TTL and may have the old IP cached for some time after I update DNS to the new server.
So, after I've thrown the switch on DNS, what I'd like to do is hack the old server to issue a forced redirect to the IP address of the new server for all visitors. Obviously I can do a number of redirects (301, 302) in either Apache or the app itself. I'd like to avoid the app method since I don't want to do a checkin and deploy of code just for this one instance so I was thinking a basic http url redirect would work. Buuttt, there are SEO implications should google visit the old site etc. etc.
How best to achieve the re-direct whilst maintaining search engine niceness?
I guess the question is - where would you redirect to? If you are redirecting to the domain name, the browser (or bot) would just get the same old IP address and end up in a redirect loop.
If you redirect to an IP address.. well, that's not going to look very user friendly in someone's browser.
Personally, I wouldn't do anything. There may be some short period where bots get errors trying to access your site, but it should all work itself out in a couple days without any "SEO damage"
One solution might be to use Mod_Proxy instead of a rewrite to proxy traffic to the new host. This way you shouldn't see any "SEO damage".
I used rinetd to redirect the IP traffic from the old server to the new one on IP level. No web server or virtual hosts config needed. Runs very smoothly and absolutely transparent to any client.