Pointing a custom path on my domain to Heroku app - heroku

I have two Heroku apps:
example-api.herokuapp.com
example-web.herokuapp.com
I also have my own domain example.com managed by Google Domains
So I would like to point:
subdomain.example.com -> example-web.herokuapp.com
subdomain.example.com/api -> example-api.herokuapp.com
Is that possible? And if so, how?
I'm aware that this structure may seem weird, but I wanted to clearly separate API and Web in two different repositories, hence two separate Heroku apps.
Thanks very much in advance.
EDIT: I have already managed to do the first part (pointing subdomain.example.com to example-web.herokuapp.com)

This cannot be done with DNS, this should be done by reverse proxying, but not recommended for APIs.
How about use
api.example.com -> exame-apo.herokuapp.com ?
It's more elegant solution for api subdomains

Related

is there a way to use different heroku regions based on location under one domain?

I'm creating a socket.io app. I like to have one url that my app would connect to. I was thinking about using freegeoip.net and computing the distance away from each region and using the closest one.
what's the best way to do it?
Heroku will not allow you to have two apps in different regions pointing to the same domain.
The best way to achieve something like this is to proxy requests to a CDN like cloudflare, which will automatically serve requests from the closest location it has.

Inter-Gear Communication for Openshift?

I'm trying to create an app such that gear 2 according to this model can be accessed by gear 3,4...n when using the --scaling option.
The idea being for this structure is the head of a chain of relays. I'm trying to find where the relevant information is so all the following gears have the same behavior. It would look like this:
I've found no documentation that describes how to reach gear 2 (The Primary DNAS) with a url (internal/external ip:port) or otherwise, so I'm a little lost as to how to let the app scale properly.
I should mention so far I've only used bash scripting, but I'm not worried about starting the program in other languages, but so long as it follows that structure in openshift I'm not worried.
The end result is hopefully create a scalable instance of shoutcast on openshift.
To Be Clear:
I'm developing a cartridge, not using the diy, all I understand of openshift is in this guide but of course I'm limited because I'm new.
I'm stuck trying to figure out how to have the cartridge handle having additional gears use the first gear as a relay. I am not confused about how Openshift routes requests externally to the gears and load balances them. I'm not lost how to use port-forwarding to connect to my app, the goal would be to design the cartridge so this wouldn't be a requirement at all, to only use external routes.
The problem as described above is that additional gears need some extra configuration, they need an available source (what better than the first gear?). In fact the solution to my issue might be to somehow set up this cartridge to bypass haproxy with an external route that only goes to the first gear.
Github for those interested, pass it around, it'll remain public. Currently this works only as a standalone, scaling it (what I'd like to fix) causes issues. I've been working on this too long by myself, so have at it :)
There's a great KB article that explains how the routing works on OpenShift gears here https://help.openshift.com/hc/en-us/articles/203263674-What-external-ports-are-available-on-OpenShift-.
On a scalable application, haproxy handles all the traffic routing to your gears. the only way to access your gears is through the ports mentioned in the article above. rhc does however provide a port-forwading option that would allow you to access things like mysql directly from your local machine.
Please note: We don't allow arbitrary binding of ports on the externally accessible IP address.
It is possible to bind to the internal IP with port range: 15000 - 35530. All other ports are reserved for specific processes to avoid conflicts. Since we're binding to the internal IP, you will need to use port forwarding to access it: https://openshift.redhat.com/community/blogs/getting-started-with-port-forwarding-on-openshift

Bypassing HTTP basic auth locally

I have two applications which I cannot change:
A: provides a URL protected by HTTP basic auth.
B: needs to access this URL but does not support basic auth.
Credentials are available.
How can I make my two applications work together?
I thought a local proxy might be great which injects the authentication. E.g. using socat:
socat TCP4-LISTEN:81,reuseaddr,fork TCP:UrlToA:80,<inject-basic-auth>=user:pass
However, socat does not provide an option like < inject-basic-auth >. Anybody knows any tool that might help? Any other way out?
You must set up a HTTP reverse proxy server that does the authentication for you. No need to hack any software.
Your reverse proxy listens on some socket (e.g. proxy:8080) and forwards requests to your actual application A, inserting the headers.
client_B ----> http://proxy:8080 -----> http://server_A:80
Nginx is lightweight, high performance and easy to set up. And it's easy to find docs online for what you want.
See for example http://wiki.apache.org/couchdb/Nginx_As_a_Reverse_Proxy
This problem seems to be very specific. So you probably won't find a ready-to-use tool.
If you want to do it yourself, your best approach is probably to extend socat:
http://www.dest-unreach.org/socat/download/socat-1.7.2.2.tar.gz
Good luck!

Point top level domain to heroku app

I want to point mysite.com to myapplication.herokuapp.com
Searched hard and was speaking with hostgator support, they say - it is impossible, heroku is not supporting A records and CNAME are not able to point from naked domain.
You can do it with A records…but Heroku really doesn't want you to, and with some good reasons. One thing you can do is run
$ host myapplication.herokuapp.com
and find out what IP that points to, and then create an A record pointing to that IP. But this is very brittle: if Heroku changes that IP, then your domain won't work until you update your A record. This method will probably break at some point, so you shouldn't do it, even though you technically can.
Luckily, there are solutions. Heroku outlines them in their documentation for custom domains, particularly in their documentation for root domains. The best one is to use a DNS provider that supports "ANAME" or "ALIAS" records, which are like CNAME records in that they point to another domain (rather than IP), but can be used for root domains. DNS doesn't natively have such support, so these are a bit of a hack, and are only supported by a few providers, namely DNSimple and DNS Made Easy. This solution is the best, most robust solution.
I use DNSimple and have found them to be very reliable and excellent to work with.
This question was already asked and answered here: https://stackoverflow.com/a/16041655/758334
I can vouch for dnsimple. There was a number of reasons why I switched to them, but their support for ALIAS records to make pointing the apex domain to hosted cloud apps was a big one for me.

Dynamic multi-domain forwarding on a simple hosting account?

My need to host a few very simple static sites on DropBox has led me to this 'exercise'.
It is probably right between serverfault and stackoverflow, but I'd say it's more programmatically.
I would like to set up a service (similar in look and feel to wasitup.com) that forwards and masks domain for anyone. This will be free, so I am looking for a quick and cheap way to do this.
In the end, my domain cute.domain.com is pointing to my server; the server is delivering a very simple frame with the link to the real content in it, something like http://dl.dropbox.com/u/2818368/test.com/index.html
This alone would be easy, just use .htaccess, nginx or Apache modules. But I would like to be able to that dynamically so that everyone can simple fill a few form fields and - presto - has it's own masquerading going.
I dream of something like a bare ruby/rack or sinatra solution that answers all the requests, checks if the hostname in the request is in a file or even in memory hash table/sqlite db and then replies with the small frame code that includes the link to the destination.
Why not just install Webmin or some other control panel that already does this?

Resources