Railway

Deploy Traefik Reverse Proxy

Self-hosted high-performance reverse proxy and load balancer 🔐

Deploy Traefik Reverse Proxy

traefik

traefik

Just deployed

/data

Deploy and Host Traefik on Railway

Traefik is a modern open-source reverse proxy and edge router used to route traffic to backend services. It supports HTTP routing, load balancing, middleware, service discovery, dashboards, and dynamic configuration, making it useful for APIs, web applications, microservices, and self-hosted infrastructure.

About Hosting Traefik

Hosting Traefik on Railway gives you a lightweight way to run a reverse proxy and routing layer in front of your services. This template can be used to route traffic to Railway private services, external HTTP services, APIs, dashboards, or self-hosted applications.

This setup uses Traefik with file-based dynamic configuration. Users can update routing rules through Railway Console or Railway CLI by editing a dynamic configuration file inside a Railway Volume. This approach is better suited for Railway than Docker provider auto-discovery, because Railway does not expose a user-managed Docker socket like a traditional Docker Compose server.

Common Use Cases

  • Reverse proxy for web applications, APIs, dashboards, and internal services
  • Routing traffic to Railway private services using *.railway.internal domains
  • Creating a lightweight edge router for microservices or self-hosted apps
  • Load balancing requests across multiple backend services
  • Managing routing rules through Railway Console or Railway CLI
  • Running a Traefik dashboard for basic proxy visibility and debugging

Dependencies for Traefik Hosting

  • Traefik Docker image
  • Railway public networking
  • Railway private networking for internal service routing
  • Optional Railway Volume mounted at /data
  • Dynamic configuration file at /data/dynamic.yml

Deployment Dependencies

Implementation Details

This template is designed to use Traefik with file-based dynamic configuration.

Recommended variables:

TRAEFIK_LOG_LEVEL=info
TRAEFIK_API_INSECURE=true
TRAEFIK_PROVIDERS_FILE_FILENAME=/data/dynamic.yml
TRAEFIK_PROVIDERS_FILE_WATCH=true
PORT=80

Recommended Railway volume configuration:

Mount Path: /data
Initial Size: 1 GB

Traefik will read dynamic routing configuration from:

/data/dynamic.yml

If TRAEFIK_PROVIDERS_FILE_WATCH=true is enabled, Traefik can watch the dynamic config file for changes. If routing does not update immediately after editing, restart the Railway service.

Important Note About Docker Provider

This template is not designed to use Traefik Docker provider auto-discovery.

Avoid using:

TRAEFIK_PROVIDERS_DOCKER=true

On a typical Docker Compose server, Traefik can discover containers using Docker labels through the Docker socket. Railway does not provide a user-managed Docker socket for this pattern, so Docker provider auto-discovery is not the recommended approach.

Use the file provider instead:

TRAEFIK_PROVIDERS_FILE_FILENAME=/data/dynamic.yml
TRAEFIK_PROVIDERS_FILE_WATCH=true

Dynamic Configuration Example

Create or update this file:

/data/dynamic.yml

Example route to one Railway private service:

http:
  routers:
    app:
      rule: "PathPrefix(`/`)"
      entryPoints:
        - web
      service: app-service

  services:
    app-service:
      loadBalancer:
        servers:
          - url: "http://your-service.railway.internal:3000"

Replace:

your-service.railway.internal:3000

with your actual Railway private service domain and port.

Example route to an external backend:

http:
  routers:
    external:
      rule: "PathPrefix(`/`)"
      entryPoints:
        - web
      service: external-service

  services:
    external-service:
      loadBalancer:
        servers:
          - url: "https://example.com"

Update Configuration via Railway Console

Open your Traefik service in Railway, then open the Console tab.

Create or overwrite the dynamic configuration:

cat > /data/dynamic.yml <<'EOF'
http:
  routers:
    app:
      rule: "PathPrefix(`/`)"
      entryPoints:
        - web
      service: app-service

  services:
    app-service:
      loadBalancer:
        servers:
          - url: "http://your-service.railway.internal:3000"
EOF

Check the file:

cat /data/dynamic.yml

If file watching is enabled, Traefik may apply the change automatically. If the route does not update, restart the service from Railway.

Update Configuration via Railway CLI

Install and authenticate Railway CLI:

railway login
railway link

Open an interactive shell inside the deployed Traefik service:

railway ssh

Create or update the dynamic configuration:

cat > /data/dynamic.yml <<'EOF'
http:
  routers:
    app:
      rule: "PathPrefix(`/`)"
      entryPoints:
        - web
      service: app-service

  services:
    app-service:
      loadBalancer:
        servers:
          - url: "http://your-service.railway.internal:3000"
EOF

Exit the shell:

exit

Restart the service if needed:

railway restart

Traefik Dashboard

This template can enable the Traefik dashboard using:

TRAEFIK_API_INSECURE=true

This is useful for testing and debugging, but it exposes the dashboard without authentication. For production use, secure the dashboard or disable insecure access.

Important Notes

  • Use /data/dynamic.yml for editable persistent routing rules.
  • Attach a Railway Volume to /data if you want config changes to survive restarts and redeployments.
  • Do not rely on Docker provider auto-discovery on Railway.
  • Use Railway private service domains such as your-service.railway.internal for internal routing.
  • If routing changes do not apply immediately, restart the Traefik service.
  • For production, avoid exposing the insecure dashboard publicly.

Why Deploy Traefik 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 Traefik 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

traefik

traefik

More templates in this category

View Template
Rocky Linux
[Jun'26] Hosted Rocky Linux 9 workspace with SSH and persistent storage. 🚀

codestorm
View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta