Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static IP Address with Heroku (not Proximo)

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?

like image 711
Allen S Avatar asked Dec 14 '13 10:12

Allen S


People also ask

How do I find my Heroku server IP address?

You can use zerigo_dns to get an static IP address for your Heroku app.

Is Heroku IP dynamic?

Because Heroku IPs are dynamic, it can be difficult to integrate Heroku applications with services that allowlist a fixed IP range, including certain APIs and services that operate behind a corporate firewall. Fixie acts as a proxy for outbound traffic, tunneling your requests through a known IP address.

Does Heroku have static IP?

Heroku does not provide Static IP addresses in the Common Runtime Environment. In Heroku Private Spaces, which costs thousands of dollars a month, Static IP's are available, but they aren't load balanced, run on dedicated proxies, or highly customizable.


3 Answers

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:)

like image 185
MicRum Avatar answered Sep 20 '22 12:09

MicRum


Fixie is another option. Fixie is an add-on that provides Heroku applications with a fixed set of static IP addresses for outbound requests. It is language- and framework-agnostic.

Fixie is easy to setup and has "get started" documentation (similar to the one for Python below) for Ruby, Node, Java, Go here. Here is the one for Python.

First you need to sign up for the free plan:

$ heroku addons:open fixie Opening fixie for sharp-mountain-4005… 

Next, the FIXIE_URL will be set as environment variable. To route a specific request through Fixie using requests:

import os, requests proxyDict = {                "http"  : os.environ.get('FIXIE_URL', ''),                "https" : os.environ.get('FIXIE_URL', '')             } r = requests.get('http://www.example.com', proxies=proxyDict) 

Using urllib2 the same functionality will look like this:

import os, urllib2 proxy  = urllib2.ProxyHandler({'http': os.environ.get('FIXIE_URL', '')}) auth   = urllib2.HTTPBasicAuthHandler() opener = urllib2.build_opener(proxy, auth, urllib2.HTTPHandler) response = opener.open('http://www.example.com') html = response.read() 

In both cases, these requests would come through a known IP address assigned by Fixie.

like image 43
user527662 Avatar answered Sep 17 '22 12:09

user527662


You can use Nginx as your reserve proxy. Edit your nginx.conf and set proxy_pass. Make sure to set proxy_set_header to your herokuapp

    upstream backend  {

            server xxx.talenox.com;

    }

    server {

            listen          80;

            server_name     rpb1.talenox.com;

            location / {

                    proxy_pass              http://backend;

                    proxy_redirect          off;

                    proxy_set_header        X-Forwarded-For $remote_addr;

                    proxy_set_header        Host ‘xxxxx.herokuapp.com’;

            }

    }
like image 32
amdstorm Avatar answered Sep 17 '22 12:09

amdstorm