Reverse Proxy Integration
MicroFly delegates public TLS termination, HTTP/2/3 handling, and ACME (Let's Encrypt) certificate management to an external reverse proxy. MicroFly's internal ingress engine binds exclusively to loopback (127.0.0.1:8000), routing requests by Host header to the active release.
Internet (Ports 80 / 443, Public TLS)
│
▼
Reverse Proxy (Caddy / Nginx / Apache2)
│ (Preserves Host & X-Forwarded-* headers)
▼
MicroFly Ingress (127.0.0.1:8000)
│ (Resolves domain -> active release)
▼
Workload Service (127.0.0.1:3000+)MicroFly provides built-in CLI helpers to generate boilerplate configuration for popular web servers:
microfly init-proxy caddy
microfly init-proxy nginx
microfly init-proxy apache21. Caddy (Recommended)
Caddy is the recommended reverse proxy for MicroFly because it handles automatic HTTPS, certificate generation, renewal, and HTTP/2/3 without manual configuration.
Generating Configuration
Run:
microfly init-proxy caddySetup Instructions
Install Caddy on Debian/Ubuntu:
bashsudo apt-get install -y debian-keyring debian-archive-keyring apt-transport-https curl curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list sudo apt-get update sudo apt-get install -y caddyEdit
/etc/caddy/Caddyfile:caddy# Global reverse proxy for all domains managed by MicroFly { # Enable automatic HTTPS email [email protected] } # Wildcard or specific domains routed to MicroFly *.example.com, example.com, *.localhost { reverse_proxy 127.0.0.1:8000 }Reload Caddy:
bashsudo systemctl reload caddy
2. Nginx
If your infrastructure standardizes on Nginx:
Generating Configuration
Run:
microfly init-proxy nginxSetup Instructions
Create
/etc/nginx/sites-available/microfly:nginxserver { listen 80; listen [::]:80; server_name example.com *.example.com; # Optional: Redirect HTTP to HTTPS # return 301 https://$host$request_uri; location / { proxy_pass http://127.0.0.1:8000; proxy_http_version 1.1; # Essential forwarding headers proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Request-ID $request_id; # WebSocket and streaming support proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; # Timeouts proxy_connect_timeout 5s; proxy_read_timeout 60s; proxy_send_timeout 60s; } }Enable the site and reload Nginx:
bashsudo ln -s /etc/nginx/sites-available/microfly /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl reload nginxFor HTTPS, use Certbot:
bashsudo apt-get install -y certbot python3-certbot-nginx sudo certbot --nginx -d example.com -d "*.example.com"
3. Apache HTTP Server (apache2)
Generating Configuration
Run:
microfly init-proxy apache2Setup Instructions
Enable required Apache modules:
bashsudo a2enmod proxy proxy_http proxy_wstunnel headers ssl rewriteCreate
/etc/apache2/sites-available/microfly.conf:apache<VirtualHost *:80> ServerName example.com ServerAlias *.example.com ProxyPreserveHost On RequestHeader set X-Forwarded-Proto "http" ProxyPass / http://127.0.0.1:8000/ ProxyPassReverse / http://127.0.0.1:8000/ </VirtualHost>Enable the virtual host and reload Apache:
bashsudo a2ensite microfly.conf sudo apache2ctl configtest sudo systemctl reload apache2
Forwarding Headers & Security Rules
MicroFly relies on the reverse proxy to sanitize external headers. For security:
Host: MicroFly routes traffic exclusively based on theHostheader. It must match a domain listed in the application'sapp.tomldomainlist.X-Forwarded-For: MicroFly walks trusted proxy chains from right-to-left to determine client IPs for rate-limiting and audit logging.X-Forwarded-Proto: Informs applications whether the client connected viahttporhttps.X-Request-ID: Passed along to backend application processes and recorded in MicroFly access logs. If absent, MicroFly generates a unique UUIDv4.