setenforce 0
nano /etc/selinux/config
systemctl stop consul
yum -y install nginx
cd /etc/nginx/conf.d/
nano services.conf
server {
server_name _;
listen 8080;
location / {
proxy_pass http://127.0.0.1:5000;
}
}
server {
server_name _;
listen 9080;
root /usr/share/nginx/html/backend-service;
}
cd /usr/share/nginx/html
mkdir backend-service
cd backend-service
echo "Backend Service" > index.html
nginx -t
systemctl start nginx
Definition for Backend Service:
cd /tmp
nano backend-service.hcl
service {
name = "backend-service"
id = "backend-service"
port = 9080
connect {
sidecar_service {}
}
check {
id = "backend-service-check"
http = "http://localhost:9080"
method = "GET"
interval = "1s"
timeout = "1s"
}
}
consul services register backend-service.hcl
nano frontend-service.hcl
service {
name = "frontend-service"
port = 8080
connect {
sidecar_service {
proxy {
upstreams = [
{
destination_name = "backend-service"
local_bind_port = 5000
}
]
}
}
}
check {
id = "backend-service-check"
http = "http://localhost:8080"
method = "GET"
interval = "1s"
timeout = "1s"
}
}
consul agent -dev --client=0.0.0.0
consul services register frontend-service.hcl
consul services register backend-service.hcl
consul connect proxy -sidecar-for frontend-service > /tmp/frontend-service.log &
consul connect proxy -sidecar-for backend-service > /tmp/backend-service.log &
netstat -ntlp
curl localhost:8080
less /tmp/backend-service.log