Report this

What is the reason for this report?

How to specify the app spec ingress field for an nginx reverse proxy service component?

Posted on January 22, 2025

Goal

I need to direct all traffic through an Nginx service component for reverse proxying, routing, rate limiting, etc.

Problem

The app runs without error on my local dev environment via Docker-Compose.

I try to update my App Platform app’s app spec from the terminal via doctl apps update <app-id>, but I get back an error: 400 (request "2887fea5-dc3a-40d2-a370-83659aa5f651") errors validating app spec; first error in field "ingress.rules.rule.match.path.prefix": rule match path prefix "/" already in use by rule with component: "nginx".

What’s strange is that even if I comment out every ingress rule in the app spec, the error still occurs.

I’m not sure about how I’m messing up. Any help is appreciated.

Note: I already have a version of my app currently running on App Platform. I’m not sure if somehow an ingress rule in the currently-running app’s app spec is causing the error.

System architecture (App Platform instance)

  • Service component: Nginx container. (reverse proxy, routing, rate limiting, …)
    • The nginx service component will handle routing to the client service component, and the api service component.
  • Service component: Client container.
  • Service component: API container.

app.yml

ingress:
  rules:
    - match:
        path:
          prefix: /
      component:
        name: nginx
        preserve_path_prefix: true
    - match:
        path:
          prefix: /ws
      component:
        name: nginx
        preserve_path_prefix: true
    - match:
        path:
          prefix: /api
      component:
        name: nginx
        preserve_path_prefix: true
services:
  - name: nginx
    ...
  - name: client
    ...
  - name: api
    ...


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,

If I understand this correctly, since your Nginx component is acting as the reverse proxy for all traffic, you only need one rule with the / prefix directed to Nginx and then Nginx will handle the rest.

Have you tried to remove any additional rules like /api and /ws since Nginx will handle the routing internally?

If you are still hitting the problem after the change, it might be worth reaching out to the DigitalOcean support team directly: https://do.co/support

- Bobby

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.