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
Fixed prefix
{componentname}
From your spec
{appname}
Your app name
Example: Three-Tier Web App
App name: webapp
fluxpostgres_webapp:5432fluxapi_webapp:3000fluxfrontend_webapp:8080Using Internal DNS in Your Code
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,
});// 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, 
portandcontainerPortshould 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:
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
CNAMEappmyblog.app.runonflux.ioapp.yourdomain.comRoot Domain Setup
CNAME@myblog.app.runonflux.ioyourdomain.comMulti-Component Public Access
Each component gets its own subdomain automatically:
frontend-webapp.app.runonflux.ioapi-webapp.app.runonflux.ioadmin-webapp.app.runonflux.io4Multi-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/usersPublic endpoint accessed from user's browser
2. API → Database (Internal)
postgresql://fluxpostgres_myapp:5432/dbnameInternal DNS - only accessible within app
3. API → Cache (Internal)
redis://fluxredis_myapp:6379Internal DNS for Redis cache
{
  "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
Application Configuration
Your application doesn't need to handle SSL - Flux handles it at the edge.
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
Connection String
const dbUrl =
  'postgresql://' +
  'user:pass@' +
  'fluxpostgres_myapi:5432/' +
  'database';Pattern 2: Frontend + API + Database
frontend-app.app.runonflux.ioapi-app.app.runonflux.iofluxpostgres_app:5432# Browser makes requests to public API endpoint
REACT_APP_API_URL=https://api-myapp.app.runonflux.ioPattern 3: Microservices with Shared Database
# 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 patternPattern 4: Redis Cache Layer
{
  "name": "redis",
  "repotag": "redis:7-alpine",
  "port": 6379,
  "containerPort": 6379,
  "cpu": 0.5,
  "ram": 1000,
  "hdd": 5
}const redis = require('redis');
const client = redis.createClient({
  socket: {
    host: 'fluxredis_myapp',
    port: 6379
  }
});Quick Reference Card
Internal Communication
flux{component}_{app}fluxpostgres_myapp:5432fluxapi_myapp:3000External Access
{app}.app.runonflux.io{component}-{app}.app.runonflux.ioyourdomain.com (CNAME)