Networking Patterns on Flux

Complete guide to networking, DNS, port mapping, and SSL/TLS configuration for Flux applications

Internal DNS

Component-to-component communication within your app

External Access

Public endpoints and custom domain configuration

SSL/TLS

Automatic HTTPS encryption for your deployments

1Flux Internal DNS Pattern

Flux provides automatic service discovery for multi-component applications using a predictable DNS pattern.

DNS Pattern Formula

flux{componentname}_{appname}

flux

Fixed prefix

{componentname}

From your spec

{appname}

Your app name

Example: Three-Tier Web App

App name: webapp

PostgreSQL DatabaseComponent: postgres
fluxpostgres_webapp:5432
API BackendComponent: api
fluxapi_webapp:3000
React FrontendComponent: frontend
fluxfrontend_webapp:8080

Using Internal DNS in Your Code

Node.js API connecting to databasejavascript
const { Pool } = require('pg');

const pool = new Pool({
  host: 'fluxpostgres_webapp',  // Internal DNS name
  port: 5432,
  database: process.env.DB_NAME,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
});
React app calling APIjavascript
// For internal component calls (backend to backend)
const API_URL = 'http://fluxapi_webapp:3000';

// For browser calls (external)
const API_URL = process.env.REACT_APP_API_URL || 'https://api.myapp.com';

2Port Mapping & Exposure

Understanding how ports work in Flux deployments and how to expose services.

Key Concepts

  • Container Port: Port your application listens on inside the container
  • Exposed Port: Port accessible from outside (Flux handles mapping automatically)
  • Internal Communication: Components can access each other on any port
  • External Access: Only explicitly exposed ports are publicly accessible

Standard Deployment

{
  "name": "api",
  "repotag": "myuser/api:latest",
  "port": 3000,
  "containerPort": 3000,
  "cpu": 1.0,
  "ram": 2000,
  "hdd": 10
}

Application listens on port 3000. Flux exposes it automatically at api.app.runonflux.io:3000

Different Port Mapping

{
  "name": "web",
  "repotag": "nginx:alpine",
  "port": 80,
  "containerPort": 80,
  "cpu": 0.5,
  "ram": 1000,
  "hdd": 5
}

NGINX listens on port 80 inside container. Accessible at web.app.runonflux.io:80

Important Notes:

  • • In most cases, port and containerPort should be the same
  • • Standard ports: HTTP (80), HTTPS (443), but you can use any port
  • • Internal DNS works regardless of which ports you expose

3Public Access & Domains

Automatic Flux Domains

Every deployed application automatically gets a Flux domain:

{appname}.app.runonflux.io

Example:

App: myblog

Domain: myblog.app.runonflux.io

Custom Domains

Point your own domain to your Flux app using CNAME records via CloudFlare:

Subdomain Setup

Type: CNAME
Name: app
Target: myblog.app.runonflux.io
Result: app.yourdomain.com

Root Domain Setup

Type: CNAME
Name: @
Target: myblog.app.runonflux.io
Result: yourdomain.com
Learn more in the Custom Domains tutorial →

Multi-Component Public Access

Each component gets its own subdomain automatically:

Frontend componentfrontend-webapp.app.runonflux.io
API componentapi-webapp.app.runonflux.io
Admin componentadmin-webapp.app.runonflux.io

4Multi-Component Communication

How different components in your application communicate with each other.

Communication Flow Example

1. Frontend → API (Browser Request)

https://api-myapp.app.runonflux.io/users

Public endpoint accessed from user's browser

2. API → Database (Internal)

postgresql://fluxpostgres_myapp:5432/dbname

Internal DNS - only accessible within app

3. API → Cache (Internal)

redis://fluxredis_myapp:6379

Internal DNS for Redis cache

Full Stack Example - Deployment Specjson
{
  "version": 4,
  "name": "fullstack",
  "description": "Complete web application stack",
  "compose": [
    {
      "name": "postgres",
      "description": "PostgreSQL database",
      "repotag": "postgres:15-alpine",
      "port": 5432,
      "containerPort": 5432,
      "environmentParameters": [
        "POSTGRES_DB=appdb",
        "POSTGRES_USER=appuser",
        "POSTGRES_PASSWORD=securepass123"
      ],
      "containerData": "s:/var/lib/postgresql/data",
      "cpu": 1.0,
      "ram": 2000,
      "hdd": 20
    },
    {
      "name": "api",
      "description": "Node.js API backend",
      "repotag": "myuser/api:latest",
      "port": 3000,
      "containerPort": 3000,
      "environmentParameters": [
        "NODE_ENV=production",
        "DB_HOST=fluxpostgres_fullstack",
        "DB_PORT=5432",
        "DB_NAME=appdb",
        "DB_USER=appuser",
        "DB_PASSWORD=securepass123"
      ],
      "cpu": 1.0,
      "ram": 2000,
      "hdd": 10
    },
    {
      "name": "frontend",
      "description": "React frontend",
      "repotag": "myuser/frontend:latest",
      "port": 80,
      "containerPort": 80,
      "environmentParameters": [
        "REACT_APP_API_URL=https://api-fullstack.app.runonflux.io"
      ],
      "cpu": 0.5,
      "ram": 1000,
      "hdd": 5
    }
  ]
}

5SSL/TLS Configuration

Automatic HTTPS

All Flux domains (*.app.runonflux.io) automatically get SSL/TLS certificates.

No configuration required - your app is automatically accessible via HTTPS.

Custom Domain SSL (via CloudFlare)

When using custom domains with CloudFlare, SSL is handled automatically:

Step 1: CloudFlare Proxy

Enable the orange cloud (proxy) in CloudFlare DNS settings

Step 2: SSL/TLS Mode

Set to Full mode in CloudFlare SSL/TLS settings

Browser → CloudFlare✓ Encrypted
CloudFlare → Flux✓ Encrypted

Step 3: Always Use HTTPS

Enable to automatically redirect HTTP → HTTPS

Full SSL setup guide in Custom Domains tutorial →

Application Configuration

Your application doesn't need to handle SSL - Flux handles it at the edge.

Dockerfile - No SSL requireddockerfile
FROM node:18-alpine

WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
COPY . .

# App listens on HTTP port only
# Flux handles HTTPS termination
EXPOSE 3000

CMD ["node", "index.js"]

Note: Your application can listen on plain HTTP. Flux terminates SSL at the edge and forwards requests to your container.

6Common Networking Patterns

Pattern 1: API + Database

Architecture

Public API endpoint
Internal DNS
🔒 Private database

Connection String

const dbUrl =
  'postgresql://' +
  'user:pass@' +
  'fluxpostgres_myapi:5432/' +
  'database';

Pattern 2: Frontend + API + Database

User Browserfrontend-app.app.runonflux.io
Frontend calls APIapi-app.app.runonflux.io
API calls DBfluxpostgres_app:5432
Frontend environment variablesbash
# Browser makes requests to public API endpoint
REACT_APP_API_URL=https://api-myapp.app.runonflux.io

Pattern 3: Microservices with Shared Database

Multiple services accessing shared databaseyaml
# Service 1: User Service
DB_HOST=fluxpostgres_platform:5432

# Service 2: Order Service
DB_HOST=fluxpostgres_platform:5432

# Service 3: Payment Service
DB_HOST=fluxpostgres_platform:5432

# All services share the same database
# Using internal DNS pattern

Pattern 4: Redis Cache Layer

Deployment Specjson
{
  "name": "redis",
  "repotag": "redis:7-alpine",
  "port": 6379,
  "containerPort": 6379,
  "cpu": 0.5,
  "ram": 1000,
  "hdd": 5
}
Connect from APIjavascript
const redis = require('redis');

const client = redis.createClient({
  socket: {
    host: 'fluxredis_myapp',
    port: 6379
  }
});

Quick Reference Card

Internal Communication

flux{component}_{app}
fluxpostgres_myapp:5432
fluxapi_myapp:3000

External Access

{app}.app.runonflux.io
{component}-{app}.app.runonflux.io
yourdomain.com (CNAME)