Configure redirects

This topic describes how to publish a service with a redirect from old.local to new.local.


Redirects do not work if a service is configured for TLS passthrough in the Interlock proxy.

  1. Create an overlay network to isolate and secure service traffic:

    docker network create -d overlay demo

    Example output:

  2. Create the service with the redirect:

    docker service create \
    --name demo \
    --network demo \
    --detach=false \
    --label,new.local \
    --label \
    --label,http://new.local \
    --env METADATA="demo-new" \

    Interlock detects when the service is available and publishes it.

  3. After tasks are running and the proxy service is updated, the application is available through http://new.local with a redirect configured that sends http://old.local to http://new.local:

    curl -vs -H "Host: old.local"

    Example output:

    * Rebuilt URL to:
    *   Trying
    * TCP_NODELAY set
    * Connected to ( port 80 (#0)
    > GET / HTTP/1.1
    > Host: old.local
    > User-Agent: curl/7.54.0
    > Accept: */*
    < HTTP/1.1 302 Moved Temporarily
    < Server: nginx/1.13.6
    < Date: Wed, 08 Nov 2017 19:06:27 GMT
    < Content-Type: text/html
    < Content-Length: 161
    < Connection: keep-alive
    < Location: http://new.local/
    < x-request-id: c4128318413b589cafb6d9ff8b2aef17
    < x-proxy-id: 48854cd435a4
    < x-server-info: interlock/2.0.0-development (147ff2b1) linux/amd64
    <head><title>302 Found</title></head>
    <body bgcolor="white">
    <center><h1>302 Found</h1></center>