Static IP Address with Heroku (not Proximo)

Allen S picture Allen S · Dec 14, 2013 · Viewed 21.7k times · Source

Is there a way to get one Static IP address for a Heroku Server? I'm trying to integrate various API's which ask for an IP address. Because of Heroku's server setup, you never have one server with a static IP - instead your IP is dynamic.

I've looked into add-ons like Proximo, however this appears to be a paid-for solution. Is there a solution where you have a static IP that you don't have to pay for?

Answer

MicRum picture MicRum · Dec 26, 2013

You can use QuotaGuard Static Heroku add-on.

QuotaGuard can be attached to a Heroku application via the command line:

$ heroku addons:add quotaguardstatic

After installing, the application should be configured to fully integrate with the add-on. When you sign up you will be provided with a unique username and password that you can use when configuring your proxy service in your application

A QUOTAGUARDSTATIC_URL setting will be available in the app configuration and will contain the full URL you should use to proxy your API requests. This can be confirmed using the next command:

$ heroku config:get QUOTAGUARDSTATIC_URL
http://user:[email protected]:9293 

All requests that you make via this proxy will appear to the destination server to originate from one of the two static IPs you will be assigned when you sign up.

You can use A simple HTTP and REST client for Ruby for detecting your IP:

$ gem install rest-client

Next, you can run the below example in an IRB session and verify that the final IP returned is one of your two static IPs.

$ irb

>require "rest-client"

>RestClient.proxy = 'http://user:[email protected]:9293'

>res = RestClient.get("http://ip.jsontest.com")

That's it:)