Heroku error 503, webSockets on multiple domains - heroku

I'm experiencing a 503 error with heroku on my project using WebSockets and a custom domain.
Connecting on http://www.mydomain.com (That point with CNAME on my heroku app)
WebSocket connection to 'ws://www.mydomain.com/shoutbox' failed: Error during WebSocket handshake: Unexpected response code: 503
Connecting on http://myapp.herokuapp.com
Everything goes allright with adress ws://myapp.herokuapp.com/shoutbox. Everything is also good in my local setup.
Is there any cross-domain issue I'm not aware off ? I'm using play!2 as server side fwk, but I don't think there is any relation to this problem.
[EDIT]
If I can only connect within my own domain then it would be fine. Cause this would be the address I'd like people to use.

I'm assuming you already enabled heroku labs:enable websockets since your herokuapp domain is working properly.
I have a hunch your DNS query is hitting a Heroku endpoint that doesn't support websockets, i.e. it's cached from before you enabled the websockets functionality.
If this behavior only happens on a single client, try flushing your DNS cache and trying again. Alternatively, make sure the DNS records for both of your domains are resolving to the same IP.

Related

How to resolve cloudflare not displaying my website on my phone

I keep having this error when I try to access my website that is hosted on aws and using cloudflare CDN.
But the surprising thing is that it is loading correctly on another person's phone.
What can be the issue and how can I resolve it?
Cloudflare error
This error specified a connection error between Cloudflare and your Origin server.
There are a couple ways this could be occurring on your device but not another's -
If you recently added Cloudflare, the DNS may still be resolving to your Origin server (for the person who it is working for). You can check this by doing a ping on their device to your domain, and seeing if it resolves to your Origin IP. Or you can check the response headers for any with CF- prefix (which means it is likely routing through Cloudflare).
Another possibility is that your Origin server is blocking some Cloudflare servers but not others. For instance when you request the site, it may be routing through Cloudflare 'Server A', while when the other person requests your site, it is routing through 'Server B'. If 'Server A' requests are failing / being blocked, this would explain the behavior you are seeing. You can check your Origin server's access logs to see if this is occurring. If it is a blocking situation, you'll want to ensure all Cloudflare's IP are whitelisted - https://www.cloudflare.com/ips/
More troubleshooting information from the Cloudflare forums - https://community.cloudflare.com/t/community-tip-fixing-error-522-connection-timed-out/42325

Is there a way to redirect CNAME www.mywebsite.com to https://www.mywebsite.com with ovh and heroku

I am hosting my nodejs app in heroku and my domain name is in OVH.
I managed to create a subdomain www and a CNAME record that points to my heroku app. It is working fine and SSL is also working fine from heroku.
I added a redirection from all subdomains to https://www.mywebsite.com and everything is working fine.
My problem is when i type www.mywebsite.com, there is no redirection and no SSL.
How can i redirect www.mywebsite.com to https://www.mywebsite.com ?
Thanks !
Unfortunately, No.
DNS maps domain names onto IP addresses, that is, it tells the client that example.com points to 12.34.56.78. HTTP vs. HTTPS is a matter of picking a port, and using the right protocol, and this is negotiated directly between client and server; DNS lookup has already happened before that.
If you want to redirect all plain-http traffic to https, you have to do it on the web server, not the DNS server.
In your situation, you could do this in node.js.
There tons of examples online for node's built-in http server or for frameworks like express. I'd recommend this solution.
But there are also solutions like Cloudflare.
They offer you a DNS Service and a proxy, which can handle such HTTP to HTTPS redirection and they even let you use their own SSL Certificate, so you don't need to buy (or let's encrypt) a SSL Certificate on your own, for example.

Request forbidden by administrative rules error for Heroku custom domain

I create a Heroku Java web application. I added pointDNS account to forward *.herokuapp.com domain to my custom domain. Forwarding is succesful and I can open my heroku application by using my custom domain. example.com and www.example.com are working. But sometimes when I open example.com it gives this error :
{
"message": "Request forbidden by administrative rules",
"__type": "CloudSearchException"
}
or
Cannot GET /
Also I can see H27 error in Heroku account. But at this time if I open www.example.com it is working.
I check ip from chromium developer tools and I see that
example.com and www.example.com is going to a different IP address. I used google dig for all ip for example.com and try all of them in browser. some of ip gives same error. Is this heroku bug or because of I set wrong rules for DNS? How can I resolve "Request forbidden by administrative rules" error?
This doesn't seem to be a configuration error, but more of a firewall kind of rule triggering which is blocking the access.
Check if you are not making too many requests, which is considered as fake or aggressive crawling and the ip getting blocked.
pointDNS resolved my issue. I am using pointDNS to set dns rules for my custom domain. I asked them about issue. They said that there are some outdated record in my account. issue was fixed when they removed them

Setting Google domains to use https

I purchased a domain (say, example.com) from Google and my Django application (say, mysite.herokuapp.com) runs on Heroku. The CNAME is set on Google to forward the http requests to the Django applicaiton on Heroku. Forwarding requests from http://mysite.example.com to mysite.herokuapp.com works just fine.
Recently, I need to introduce progressive-web-application to my application and it requires the https protocol, instead of http, that is, the URL now has to be https://mysite.example.com and it doesn't work for Google domains. I tried https://mysite.herokuapp.com and it works fine, which means Heroku already supports https. However, I tried (and also googled) for a long time without finding a solution.
So how do I set the Google domain to use https protocol?
The DNS answer from Google cannot contain the port or protocol (http vs. https), it just contains the hostname.
You need to add a redirect from http to https in the Heroku django app, see e.g. here for more instructions.
It's not Google you need to change, it's your Django configuration.
Set SECURE_SSL_REDIRECT to True, and enable the SecurityMiddleware in your app, and any requests should automatically be redirected from HTTP to HTTPS.
When switching to HTTPS you need to add certs to heroku and that process updates the host from "mysite.heroku.com" to something like "tokyo-2121.herokussl.com". You will need to update your DNS to serve HTTPS pages from the new SSL compliant heroku instance for both HTTP and HTTPS.
Here is a tutorial that outlines the process with Godaddy, it should be very similar or all DNS providers.
http://www.joshwright.com/tips/setup-a-godaddy-ssl-certificate-on-heroku
Just got a solution from one of Heroku's engineers:
1) Upgrade the Heroku app to a paid one (e.g., Hobby)
2) On the DNS provider's settings, set the DNS target to <app_name>.<domain>.herokudns.com (e.g., "mysite.example.com.herokudns.com")
3) Run $ heroku certs:auto:refresh -a <app_name> (e.g., $ heroku certs:auto:refresh -a mysite)
I'm not sure if this is the same problem that you ran into, but when forwarding from https://example.com to my wix subdomain https://learn.example.com, I got a "No resource with given identifier found" error in the browser. Forwarding from http://example.com to https://learn.example.com was working just fine.
I had to open Google Domains' advanced forwarding options for my forwarding rule and enable SSL forwarding, like so:

No 'Access-Control-Allow-Origin' issue, despite all resources being on same domain

I am writing a javascript/strophejs xmpp client, and have been so far using it to connect to a xmpp server hosted at hosted.im, via a public BOSH service (http://bosh.metajack.im:5280/xmpp-httpbind). The html/javascript is also hosted online, at testserver.host56.com (not the real url).
Now, I decided to host the xmpp server on the amazon web cloud, and use my own Bosh service, hosted on this server as well.
Now, my ec2 instance is at myAWSDNS.us-west-2.compute.amazonaws.com (also not real url).
I also have a BOSH service up and running, at myAWSDNS.us-west-2.compute.amazonaws.com:7070.
Finally, I have also allowed traffic to this ec2 instance through both the instances firewall and through the AWS Security Group policy.
However, when trying to connect to this instance's xmpp server (openfire), using my JS/strophejs client, I get the following message in the Chrome javascript console:
XMLHttpRequest cannot load http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://myAWSDNS.us-west-2.compute.amazonaws.com' is therefore not allowed access
Why am I getting this issue, if the origin is on the same domain as the requested resource?
The Ec2 instance is running Windows Server 2012.
This is the code I use to log in:
var conn = new Strophe.Connection("http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/");
conn.connect("chris#myAWSDNS.us-west-2.compute.amazonaws.com", "myPassword", somecallback);
Thanks,
best regards,
Chris
As previously mentioned, even if you're on the same domain, the ports must also match otherwise CORS is required.
You may not be using the correct URL for your connection manager, all of the ones I've seen use an address ending in /http-bind/ or similar.
Have you tried connecting with Strophe.Connection("http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/http-bind/");?
Also, you can test for the presence of the crossdomain.xml file by simply visiting http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/crossdomain.xml to ensure that CORS has been successfully enabled.
The browser will not allow since the ports are different. I don't know what you have at AWS, but you can proxy the request in both direction, like as:
http://myAWSDNS.us-west-2.compute.amazonaws.com/http-bind/ <---------> http://myAWSDNS.us-west-2.compute.amazonaws.com:7070/
See item no 5: Connecting with Strophe.js of the tutorial for Apache use case.

Resources