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: ehazlett/interlock-default-app 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, use
com.docker.lb.backend_mode=vip
.
The following is an example configuration to use with the NGINX extension.
ListenAddr = ":8080"
DockerURL = "unix:///var/run/docker.sock"
PollInterval = "3s"
[Extensions.default]
Image = "mirantis/interlock-extension-nginx:3.3.16"
Args = ["-D"]
ServiceName = "interlock-ext"
ProxyImage = "mirantis/ucp-interlock-proxy:3.3.16"
ProxyArgs = []
ProxyServiceName = "interlock-proxy"
ProxyConfigPath = "/etc/nginx/nginx.conf"
ProxyStopGracePeriod = "3s"
PublishMode = "ingress"
PublishedPort = 80
ProxyReplicas = 1
TargetPort = 80
PublishedSSLPort = 443
TargetSSLPort = 443
[Extensions.default.Config]
User = "nginx"
PidPath = "/var/run/proxy.pid"
WorkerProcesses = 1
RlimitNoFile = 65535
MaxConnections = 2048
See also