logo

Networking

Understanding Ports in Swiftor

Because Swiftor runs your VMs in Docker containers, networking works differently than on your local computer. Let's understand how:

Local vs Container Networking

Architecture Diagram

On your computer:

  • Programs listen on ports directly
  • Traffic routes straight to your programs
  • localhost means your computer

In Swiftor:

  • VMs run in isolated containers in a user-stack
  • Each user-stack has its own network
  • We need to map container ports to domains

Domain Mapping

When you create a subdomain mapping in Swiftor:

  1. External domain → Container port
  2. Example: myapp-vmid.swiftor.ioContainer:5001

Default Port

All subdomains are served on port 80 (HTTP) and 443 (HTTPS) externally.

Managing Network Mappings

The Network Manager

Access the network manager through the workspace:

Network Manager

Components:

  • Subdomain input
  • Internal port selector
  • VM dropdown
  • Preview URL

Adding a Mapping

  1. Enter your desired subdomain
  2. Specify the internal port
  3. Select target VM
  4. Click Save
yaml
Example Mapping:
  Subdomain: myapp
  Internal Port: 5001
  VM: 228782df-e228-4b7a-b341-d267724c745e
  Result URL: myapp-228782df-e228-4b7a-b341-d267724c745e.swiftor.io

Managing Mappings

Your existing mappings appear in a table showing:

ColumnDescription
SubdomainYour chosen name
Internal PortPort inside VM
VMTarget virtual machine
Preview URLFull access URL

Hot Restart

Changes require a hot restart of the networking service to take effect.

Common Use Cases

Web Applications

yaml
Subdomain: webapp
Internal Port: 3000
Use Case: React/Node.js apps

API Services

yaml
Subdomain: api
Internal Port: 8080
Use Case: Backend services

Database Admin

yaml
Subdomain: db
Internal Port: 8081
Use Case: phpMyAdmin

Security Considerations

Security Warning

  • Internal ports are only accessible through subdomain mappings
  • All traffic is TLS encrypted
  • Consider VM firewall rules

Best Practices

  1. Only expose necessary ports
  2. Use descriptive subdomains
  3. Monitor access logs
  4. Implement authentication

Troubleshooting

Common issues and solutions:

IssueSolution
Port in useCheck running services
Can't accessVerify VM is running
SSL errorsWait for cert provision