I need to forward my default heroku domain http://app1name.herokuapp.com to http://app2name.herokuapp.com ? Is this possible with heroku?
As per Redirect from "mysite.herokuapp.com" to "www.mysite.com", you probably need functionality in that app (app1name) to redirect requests to app2name - preferably with a HTTP 302 or 301 response.
Related
I recently added Fastly domain from addons in heroku application. And when fastly was provisioned I got a test url which is as follows:
https://felix-homes-herokuapp-com.global.ssl.fastly.net/
Whenever I click on this url it gets redirected to
https://felix-homes.herokuapp.com for some unknown reason.
Note my nodejs app uses Heroku-SSL-Redirect. Is it because of this?
I have already followed setup guide and asked multiple issues from the support
https://support.fastly.com/hc/en-us/requests/323620?page=1
And nearest question I find to SO is following
Adding Fastly to a Heroku app does not forward to proper url
Clearing browser cache or changing browser did not help me. Can you please try hitting fastly url on your computer and let me know if you are also face same redirect problem?
Yes, very likely the library (Heroku-SSL-Redirect) is the issue.
In the end, you have two separate requests. An encrypted HTTPS/SSL request from the browser. And then an unencrypted request from Fastly to Heroku.
Your node-application and the library only see the unencrypted request and return the redirect.
There are two ways to solve this:
You configure Fastly do do encrypted requests to Heroku as its backend.
Every routing / proxy layer (fastly, but also the Heroku routing layer) typically use the X-Forwarded-Proto HTTP header to tell the backend application that the initial request was already encrypted. So either heroku-ssl-redirect doesn't look at the header, or it did get lost somewhere on way.
Using the routing rules as mentioned here: Set up DNS based URL forwarding in Amazon Route53
<RoutingRules>
<RoutingRule>
<Redirect>
<Protocol>https</Protocol>
<HostName>dota2.becomethegamer.com</HostName>
<HttpRedirectCode>301</HttpRedirectCode>
</Redirect>
</RoutingRule>
</RoutingRules>
I am able to see that http://becomethegamer.com properly redirect to https://dota2.becomethegamer.com but https://becomethegamer.com times out.
I thought it was the Protocol piece but realized that's the outbound rather than inbound.
This is in a bucked named becomethegamer.com and in Route 53 becomethegamer.com is an alias with the target as that bucket.
What could be causing https to not redirect?
No, it's this:
The website endpoints do not support https.
http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html
You can't redirect an https request without speaking https, and additionally, you need an SSL certificate that's valid for the hostname.
You can still do exactly what you're trying to do, but you'll need to use CloudFront in front and S3 in the back. Your S3 redirection configuration stays the same, but you'll create a CloudFront distribution, configure your domain name as an alternative domain name there, load your SSL cert into CloudFront, use the bucket-name.s3-website-xx-xxxx-xx.amazonaws.com web site endpoint (from the S3 console) as the Origin server, and point Route 53 to CloudFront instead of S3.
http://docs.aws.amazon.com/gettingstarted/latest/swh/getting-started-create-cfdist.html
I'm trying to redirect all https traffic to http using this in Sinatra
get "*" do
if request.secure?
redirect request.url.gsub(/^https/, "http")
else
pass # continue execution
end
end
However, on a custom domain on heroku, my browser shows me the error:
This is probably not the site you are looking for!
You attempted to reach www.[domain].com, but instead you actually reached a server identifying itself as *.heroku.com.
My DNS is configured with the www subdomain having a CNAME pointing to [domain].herokuapp.com as per https://devcenter.heroku.com/articles/custom-domains
Is this a DNS issue? Is buying a SSL certificate the only way to allow all https traffic to redirect to http, on heroku?
If you were going to use that code then I'd make it a before filter, as that's really what it is.
However, if you've received a request at the application layer (which is where your Sinatra app sits on Heroku) then you need a certificate because the HTTP layer (where the Nginx proxy servers that deal with this sit) has already received the request and will attempt to deal with it as a secure connection but fail/raise an error because there's no certificate. That is the message you'll get if you try and reach an non SSL page/site via the https URI scheme. You can still access the site but the user has to click past a scary warning.
The only way I know of that may work without a certificate (but looking at this answer probably not) is if you had access to the Nginx configuration and did the rewrite of the URL (and probably some headers) there.
So I purchased a domain from 1and1, say it's www.mysite.com, and am hosting my app on Heroku myapp.herokuapp.com. I have two options for forwarding the domain - HTTP and Frame. HTTP forwarding seems to just redirect my URL from www.mysite.com to myapp.herokuapp.com, which isn't what I want. But I am having a problem with Frame redirecting - if I navigate on my site to various pages (e.g. myapp.herokuapp.com/users), it will still say www.mysite.com on the top, but not www.mysite.com/users. How can I get the URL path to display correctly?
You don't want to use the (i)frame method - it's bad practice and you'll get the issues you're having now.
What you probably want to do is:
Attach www.yourdomain.com to your Heroku app (via the web interface or the CLI[1])
Set up a CNAME record to point www to yourapp.herokuapp.com with your DNS provider, or use the Zerigo DNS[2] add-on if you don't have DNS hosting already (sounds like you do)
(Optional) Set up a re-direct to direct http://yourdomain.com to http://www.yourdomain.com, via your DNS provider/domain registrar - this is optional, but useful as Heroku does not recommend pointing your root domain (yourdomain.com) to their A records in case they change.
(Optional) Re-direct http://myapp.herokuapp.com/ to http://www.yourdomain.com/ from within your application code or similar (e.g. config.ru if you're using Rack to serve your content)
[1] https://devcenter.heroku.com/articles/custom-domains
[2] https://addons.heroku.com/zerigo_dns
How would one setup a redirect from example.com to www.example.com using Heroku and Cloudflare?
It's not something that you can do at CloudFlare since they now host the DNS for your domain and don't support redirects so it's something you'd have to do at the application level.
http://support.cloudflare.com/discussions/questions/259-redirect-to-www
One free way to do it is to use the Naked Domain Redirect from wwwizer.com. You just make an A record for example.com to 174.129.25.170 (you can do that from Cloudflare). wwwizer will then redirect the request to www.example.com. It's probably the easiest way that I know how to do it.
Your best bet here is to do the redirect with something like Rack-rewrite, or at the DNS level if you're hosting DNS on Zerigo.