[root@localhost ~]# cd consul/
[root@localhost consul]# ls
consul_0.9.2_linux_amd64.zip
[root@localhost consul]# vim nginx.ctmpl
upstream http_backend {
{{range service "nginx"}}
server {{.Address}}:{{.Port}};
{{end}}
}
server {
listen 1216;
server_name localhost 192.168.88.137;
access_log /var/log/nginx/kgc.cn-access.log;
index index.html index.php;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Client-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://http_backend;
}
}
3.在consul服务器上安装nginx
###### 准备nginx-1.12.2软件包
###### 安装编译:
[root@localhost ~]# yum install -y gcc pcre-devel zlib-devel
[root@localhost ~]# tar xzvf nginx-1.12.2.tar.gz -C /opt
[root@localhost nginx-1.12.2]# ./configure --prefix=/usr/local/nginx
[root@localhost nginx-1.12.2]# make && make install
4.配置nginx:
[root@localhost nginx-1.12.2]# vim /usr/local/nginx/conf/nginx.conf
http {
include mime.types;
include vhost/*.conf; //添加虚拟主机文件
default_type application/octet-stream;