rvs-prxy/Design_Doc/Port_Exposure_Guide.md
2026-06-21 01:39:43 +00:00

2.4 KiB

Port Exposure Feature - Quick Guide

Overview

The port exposure feature allows you to expose host ports directly to container ports without requiring domain-based routing. This is useful for internal services, development environments, or any service accessed via IP:port.

How It Works

  • Traditional Domain Routing: https://app.example.com → Traefik → Container
  • Port-Based Routing: http://<host-ip>:18081 → Traefik → Container

Setup Example

Scenario

You have an nginx container running and want to expose it on host port 18081:

CONTAINER ID   IMAGE          COMMAND                  PORTS     NAMES
933e8528ec28   nginx:1.29.7   "/docker-entrypoint.…"   80/tcp    ph-web-1003-nginx_cntr

Step 1: Create Port Configuration File

Create .env.port-18081:

HOST_PORT="18081"
CONTAINER_NAME="ph-web-1003-nginx_cntr"
CONTAINER_PORT="80"

Step 2: Run the Script

curl -s "https://www.ivantito.com/app-pub/demos/test/deploy-rvs-prxy.sh" | bash

Step 3: Access the Service

http://<your-host-ip>:18081

Batch Setup Example

Create multiple port configuration files:

.env.port-18081
.env.port-18082
.env.port-18083

Run the script once - it will process all port configs automatically:

curl -s "https://www.ivantito.com/app-pub/demos/test/deploy-rvs-prxy.sh" | bash

Expected output:

[INFO] Found 3 port config files, will process all in batch mode
[INFO] =========================================
[INFO] Processing port 1 of 3: .env.port-18081
[INFO] =========================================
[INFO] Setting up port exposure: Host port 18081 -> Container nginx-1:80
[INFO] Port exposure 18081 has been configured in Traefik
[INFO] Service will be accessible at: http://<host-ip>:18081
...
[INFO] Batch processing completed: 3 port(s) processed

Configuration File Location

Place .env.port-* files in the same directory as your .env file (current directory or script directory).

Technical Details

  • Creates Traefik entry point for each port
  • Generates dynamic routing configuration
  • No Traefik restart required (auto-loads configuration)
  • Works with any Docker container on the host

Use Cases

  1. Internal Services: Admin panels, monitoring dashboards
  2. Development/Testing: Quick access without domain setup
  3. API Services: Direct port access for API endpoints
  4. Multiple Services: Different ports for different containers on same host