- The DevOps 2.1 Toolkit:Docker Swarm
- Viktor Farcic
- 362字
- 2021-07-09 21:03:39
Running a service through a reverse proxy
We want the go-demo service to be able to communicate freely with the go-demo-db service and to be accessible only through the reverse proxy. We already know how to accomplish the first part. All we have to do is make sure that both services belong to the same network go-demo.
How can we accomplish the integration with a reverse proxy?
We can start by creating a new network and attach it to all services that should be accessible through a reverse proxy:
docker network create --driver overlay proxy
Let's list the currently running overlay networks:
docker network ls -f "driver=overlay"
The output is as follows:
NETWORK ID NAME DRIVER SCOPE
b17kzasd3gzu go-demo overlay swarm
0d7ssryojcyg ingress overlay swarm
9e4o7abyts0v proxy overlay swarm
We have the go-demo and proxy networks we created earlier. The third one is called ingress. It is set up by default and has a special purpose that we'll explore later.
Now we are ready to run the go-demo service. We want it to be able to communicate with the go-demo-db service so it must be attached to the go-demo network. We also want it to be accessible to a proxy (we'll create it soon) so we'll attach it to the proxy network as well.
The command that creates the go-demo service is as follows:
docker service create --name go-demo \
-e DB=go-demo-db \
--network go-demo \
--network proxy \
vfarcic/go-demo:1.0
It is very similar to the command we executed in the previous chapter with the addition of the --network proxy argument:
Now both services are running somewhere inside the cluster and can communicate with each other through the go-demo network. Let's bring the proxy into the mix. We'll use the Docker Flow Proxy (https://github.com/vfarcic/docker-flow-proxy) project that is a combination of HAProxy (http://www.haproxy.org/) and a few additional features that make it more dynamic. The principles we'll explore are the same no matter which one will be your choice.
Please note that, at this moment, none of the services are accessible to anyone except those attached to the same network.
- 亮劍.NET:.NET深入體驗(yàn)與實(shí)戰(zhàn)精要
- 火格局的時(shí)空變異及其在電網(wǎng)防火中的應(yīng)用
- 自動(dòng)控制原理
- 手把手教你玩轉(zhuǎn)RPA:基于UiPath和Blue Prism
- 信息物理系統(tǒng)(CPS)測(cè)試與評(píng)價(jià)技術(shù)
- Learning Azure Cosmos DB
- 分析力!專業(yè)Excel的制作與分析實(shí)用法則
- 教育機(jī)器人的風(fēng)口:全球發(fā)展現(xiàn)狀及趨勢(shì)
- 嵌入式操作系統(tǒng)原理及應(yīng)用
- 青少年VEX IQ機(jī)器人實(shí)訓(xùn)課程(初級(jí))
- 電腦故障排除與維護(hù)終極技巧金典
- Cisco UCS Cookbook
- 設(shè)計(jì)中的人因:34個(gè)設(shè)計(jì)小故事
- 深度學(xué)習(xí)實(shí)戰(zhàn)
- Learning Kibana 7(Second Edition)