5

Static IP on Heroku – How to get one

It’s easy to get a static IP on Heroku. Here’s how.

Why would you need a static IP address for your Heroku app?

You may need to add a firewall rule to your systems so you can access a protected internal database or API. Maybe you want to access a third party’s API and they only accept traffic from specified IPs.

The good news is that you can get the benefits of Heroku’s horizontal scalability and all the other goodness it offers whilst still routing your critical traffic through a static IP. I’m going to be talking about outbound traffic only here. If you need all inbound traffic to go via a static IP maybe, check out our inbound service also available on Heroku called QuotaGuard Static.

Option 1: Do it yourself

DIY iconIf you want to get involved with setting up and managing servers then it it is possible to set this up yourself using a traditional hosting provider like AWS, Rackspace or Digital Ocean.

Elad Ben-Israel has a blog post with more details on how to set up a proxy using Squid on AWS.

The good bits

  • Control over how your proxy works and what traffic you allow through it.

The ugly truth

  • All of a sudden you’re managing servers with all of the maintenance, monitoring and upgrade pain that it brings.
  • What is your failover strategy? If your proxy is handling critical traffic then what happens when you’re AWS box falls over? At the very least you will need another box for a load balancer and one more for a backup proxy. Your maintenance load just got much worse.

Isn’t not worrying about this kind of problem why you moved to Heroku in the first place?

Option 2: Use a hosted proxy service

static ip icon
Ahhh, the “Heroku Way” – let other people worry about boring infrastructure so you can build awesome apps.

By using a hosted service like QuotaGuard Static you will be provided with a static IP that your traffic will route through. No server setup or management required. All you need to do is configure your app to direct the outbound traffic through the proxy server provided.

Available on the Heroku add-ons marketplace you can add QuotaGuard Static to your app in one click.

The good bits

  • No infrastructure to manage
  • Built in fault tolerance. With QuotaGuard Static you actually get a primary and secondary IP that are hidden behind a load balancer. This means that if one static IP fails traffic will automatically be routed through the secondary IP and your critical traffic is not affected.

The ugly truth

  • It’s not free

Other providers?

We think QuotaGuard Static is the best option but it isn’t the only one. The first provider to offer this service on Heroku was Proximo. Whilst it does the job it is a side project run by a Heroku engineer and has no fault tolerance. If you are an independent developer who wants to send non-critical traffic through a static IP then Proximo may be ok but for any critical traffic we think QuotaGuard Static is more appropriate (it’s also cheaper and better value!).

Learn More about QuotaGuard Static

Quota Guard Team

5 Comments

  1. hi, would option 1 not work for inbound traffic? thanks

    • For inbound traffic you would need to set up your own instance running a reverse proxy like HAProxy which forwards all traffic on to your Heroku app.

      It’s not something we offer or recommend as you throw away a lot of the scalability benefits of Heroku by forcing all your traffic to go through a single EC2 instance.

  2. Hi, would I be able to use this to get a Google+ / Facebook API key set up for my app login? If so, how would I do it using your service and Heroku?

    • I’m not too familiar with the constraints of Google+ and Facebook but our service works with any third party API that requires you to provide a static IP address that your traffic originates from.

      How it integrates with each API depends on how you plan to access it, e.g. directly over HTTP or through a client library like a Ruby gem and what language your app is written in.

      We have a large number of starter solutions on our Documentation site but if you’ve still got questions send us an email and we can walk you through setup.

Comments are closed.