Create a proxy service¶
If you want to customize the default NGINX proxy service used by MKE to provide layer 7 routing, follow the steps below to create an example proxy service where users will be redirected if they try to access a route that is not configured.
To create an example proxy service:
Create a
docker-compose.yml
file:version: "3.2" services: demo: image: httpd deploy: replicas: 1 labels: com.docker.lb.default_backend: "true" com.docker.lb.port: 80 networks: - demo-network networks: demo-network: driver: overlay
Download and configure the client bundle and deploy the service:
docker stack deploy --compose-file docker-compose.yml demo
If users try to access a route that is not configured, they are directed to this demo service.
Optional. To minimize forwarding interruption to the updating service while updating a single replicated service, add the following line to the
labels
section of thedocker-compose.yml
file:com.docker.lb.backend_mode: "vip"
And then update the existing service:
docker stack deploy --compose-file docker-compose.yml demo
Refer to Use service labels for information on how to set Interlock labels on services.