Static IP Address with Heroku (not Proximo) [closed]
Asked Answered
A

3

34

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?

Ayesha answered 14/12, 2013 at 10:3 Comment(2)
I don't think there is such an option. Heroku only has a handful of IPs, and those are mapped to their http routers. Maybe there are workarounds that can work for you, though. What APIs, and what exactly do they require?Germiston
What did you end up using in the end? Wouldn't it be easier to get a VPS, used as a sub-domain, somewhere just for those things you need a dedicated IP with? Wondering myself the same question (considering moving to Heroku and I need a dedicated IP for my e-mail needs.)Cithara
S
25

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

Species answered 25/12, 2013 at 23:28 Comment(3)
Actually Quotaguard offers two products, and the one available as a Heroku add-on is not the static IP proxy. If you want a static IP you should follow the subscription process on their site: quotaguard.com/pricing#_quotaguardstaticDuodecimo
Both add-ons are in the Marketplace now. Quotaguard Static for static IPs, Quotaguard for dynamic non-Heroku IPs.Atmo
openguard (and fixie) give you two IPs. Is there any option for when There Can Be Only One? The API I'm consuming requires an access key that they create by encrypting a registered IP. I can register more than one IP, but each request must contain a key that matches the IP of the request.Rollick
S
9

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.

Silkstocking answered 26/9, 2015 at 23:35 Comment(5)
Note that this is currently not available in eu region, only us region.Consumedly
Still the case to this day!Zindman
No longer the case!Astray
Also note that the set of ip addresses you get may be fixed, but may not be dedicated for you. That means that fixie may use a limited pool of IP-addresses where they distribute some of them to their clients.Chronaxie
There is a way to get only 1 IP for fixie? It provide 2 different IP by default and it looks like it pick randomly one of themCounterrevolution
M
2

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’;

            }

    }
Minny answered 10/1, 2015 at 9:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.