Deploy Second Port
Expose a second container port on its own public Railway domain via Caddy
Second Port
Just deployed
Deploy and Host Second Port on Railway
Second Port is a lightweight Caddy reverse proxy for Railway. It gives a second container port its own public HTTPS domain while forwarding traffic to the target service over Railway's private network—ideal when one service listens on multiple ports but Railway only exposes one per domain.
About Hosting Second Port
Deploy Second Port as a separate Railway service alongside the application you want to expose. The proxy listens on port 3000 and forwards all requests to a target hostname and port you configure with TARGET_DOMAIN and TARGET_PORT. Railway handles TLS on the public domain; Caddy handles reverse proxying over the private network with dynamic DNS resolution, load balancing across replicas, and passive health checks.
Before deploying, ensure your target service listens on a fixed port and binds to :: so it is reachable over Railway private networking. Set reference variables pointing at the target service's RAILWAY_PRIVATE_DOMAIN and the port to expose, then assign a public domain to this proxy service with port 3000. No database or persistent storage is required.
Common Use Cases
- Exposing an admin UI or internal API on a dedicated public URL while the main app keeps its primary domain
- Publishing a secondary endpoint from multi-process containers (e.g. frontend on one port, backend API on another)
- Giving webhooks, WebSockets, or auxiliary services a separate domain without running a second full deployment
Dependencies for Second Port Hosting
- A target Railway service running in the same project and environment
- The target must bind to
::on the port you want to expose TARGET_DOMAINandTARGET_PORTconfigured on this proxy service
Deployment Dependencies
- Railway private networking
- Railway service variables and reference variables
- Caddy reverse_proxy
- Caddy dynamic upstreams
Implementation Details
Configure the proxy service with reference variables to your target:
TARGET_DOMAIN=${{MyService.RAILWAY_PRIVATE_DOMAIN}}
TARGET_PORT=8080
Or pass both in one variable:
TARGET_HOST=${{MyService.RAILWAY_PRIVATE_DOMAIN}}:8080
Assign a public domain to this proxy service and set its port to 3000. Example layout:
- Main service —
https://myapp.up.railway.app→ port3000 - Second Port proxy —
https://myapp-admin.up.railway.app→ port3000, forwarding to target port8080
Why Deploy Second Port on Railway?
Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.
By deploying Second Port on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.
Template Content
Second Port
douglasrubims/railway-second-portTARGET_PORT
Target port
TARGET_DOMAIN
Target private domain
