consul部署及启动完成后,查看节点:
curl 127.0.0.1:8500/v1/catalog/nodes
使用DNS协议查看节点信息:
dig @127.0.0.1 -p 8600 Litao-MacBook-Pro.node.consul
若需要web-ui查看,需配置一个代理。nginx代理配置如下:
server {
listen 8081;
server_name 192.168.1.61;
location / {
proxy_pass http://127.0.0.1:8500;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forward-For $proxy_add_x_forwarded_for;
proxy_set_header Access-Control-Allow-Origin *;
proxy_next_upstream http_502 http_504 error timeout invalid_header;
}
}
配置后web如下图所示: