Report this

What is the reason for this report?

Reverse proxy running on a droplet as a workaround for the lack of static IP's in the App Platform

Posted on October 10, 2022

Hi everyone,

The App Platform is working great, however a major drawback we’re seeing is that there is no option to give it a dedicated, static IP (or a range of IP’s). This means we cannot whitelist our applications running on the App Platform to access resources hosted elsewhere.

I’m certainly not the only one running into this problem, as there’s a suggestion with a bunch of upvotes already about this topic: https://ideas.digitalocean.com/digitalocean/p/app-platform-static-ip

However, until DigitalOcean provides this functionality, I was trying to use the following workaround. What if I spin up a Droplet with an NGINX running, which acts as a proxy to those external systems. So my App Platform apps will call this droplet, and the droplet will forward the request. Since we can give reserved IP’s to droplets, this should work; right?

My main question is now, has someone already tried this? I’ve been messing with NGINX configs for the better part of the day, and I’m yet to come up with a working solution. In my case I need to proxy to a MySQL and Postgres DB.

Can anyone a) confirm this should be working, and b) happen to have a working configuration for NGINX (or another proxy solution)?

Thanks!



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

Quick update here, you can now add dedicated egress IP addresses to your apps on App Platform. Dedicated egress IP addresses allow your app to connect to resources outside of DigitalOcean using a publicly available static IP address.

Dedicated egress IP addresses are a paid feature that allows your app to connect to resources outside of DigitalOcean using a static IP address and allow you to restrict external resources to receive only outgoing traffic from your app. Dedicated egress IP addresses persist through redeployments but are removed from the app if you disable the feature or the app is destroyed.

You can add a dedicated egress IPs to your app after you deploy the app. To do so, in the DigitalOcean Control Panel, go to the Apps page and click your app. Click the Settings tab, scroll to the Dedicated Egress IP Addresses section, and then click the Edit button beside the section.

In the Edit menu, click the Add Dedicated Egress IP button. This assigns two IP addresses to your app and triggers a redeployment.

To remove a dedicated egress IP address, in the same Edit menu, click Release Dedicated Egress IPs. This removes the IP addresses from the app and triggers a redeployment. Once IP addresses have been released, the same addresses cannot be re-added to the app.

Hope that this helps!

Best,

Bobby

Hi there,

The Nginx config should looks something like this:

stream {
  upstream db {
    server your_external_mysql_serivce:3306;
  }

  server {
    listen 3306;
    proxy_pass db;
  }
}

Note that the stream directive, would need to be outside the http directive in order for this to work.

Let me know how it goes and if you are getting any specific errors!

Best,

Bobby

While this approach works, there’s apparently still no way to add your APP in the same VPC as your droplet; so for this to work you need to allow ALL IPV4 connections to your droplet; which is far from ideal.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.