Nginx proxy for micro-frontend apps over 6PN private network (single domain)

Hello, I’ve been looking at Fly.io as a potential platform to host our micro-frontend apps on the same domain name. I’d like to get a better idea if it’s possible to setup a similar proxy architecture in front of multiple apps as what I’m used to on other platforms. Or what the Fly way is to do it.

Would it be possible to get an updated 2022 example or tutorial of how to run an nginx proxy in front of multiple apps connecting with a 6PN private network on Fly.io?

  1. I tried reading this blog article - Incoming! 6PN Private Networks · Fly
  2. And following this example - GitHub - fly-apps/nginx-cluster: A horizontally scalable NGINX caching cluster
  3. However, it’s failing this error:
    2022-05-01T21:19:47Z   [info]web | /fly/check-nodes.sh: line 12: dig: command not found
    

The setup

Four Fly apps: one proxy and three micro-frontends:

  1. example-proxy (nginx proxy)
  2. example-blog (Node app)
  3. example-docs (Python app)
  4. example-web (Remix app)

Given the following URLs, the proxy would route traffic like:

example.com/blog → routes to example-blog
example.com/docs → routes to example-docs
example.com/* → routes everything else to example-web

Also, would it be possible to use the internal DNS name without having to inject the IP6 address in the nginx.conf and use the internal DNS records directly? Like:

upstream example-blog {
  server example-blog.internal;
}

upstream example-docs {
  server example-docs.internal;
}

upstream example-web {
  server example-web.internal;
}

server {
  listen 8080;
  listen [::]:8080;

  location /blog {
    proxy_pass http://example-blog/;
  }

  location /docs {
    proxy_pass http://example-docs/;
  }

  location / {
    proxy_pass http://example-web/;
  }
}

Hey there. The config you posted here should work. Have you tried it yet with ‘standard’ nginx? You can do that by following Dockerfile app deployment instructions.

Once you have all the other apps up, you can do something like this in your proxy app Dockerfile:

FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf

If you need help figuring out how to get the proxy app started, reply here and we can give you further guidance.

Hi Joshua, thank you for the reply and looking into this issue.

The article linked above, Dockerfile app deployment instructions, is more about Docker. However, the question I have is more about how private networking (6PN) can be used to connect between apps within an organization on Fly.

I do already have an nginx app up and running in an organization on Fly.

  • It’s already able to proxy for services hosted on other external platforms.
  • Now, I’m trying to get it to proxy for services thru 6PN private networking within the same organization at Fly.

I tried the config above and it didn’t work. Is there a newer/better way to get the 6PN private networking address to be used as an upstream server in the proxy config?

On which port are your other services running? You’ll want to include that port in the upstream like server example-web.internal:8080;