本文共 734 字,大约阅读时间需要 2 分钟。
首先创建upstream
curl -i -X POST --url -d "name=user_service_upstream"之后添加后端服务curl -i -X POST --url -d "target=192.168.195.129:80"curl -i -X POST --url -d "target=192.168.195.130:80"查看upstream 里面的targetcurl -i -X GET --url 添加到apicurl -i -X POST --url -d "name=user_service_lb" -d "hosts=www.test.com" -d "upstream_url="ps -ef | grep nginx
cd /usr/local/openresty/nginx/conf/vi nginx.conf在最后添加include vhosts/*.conf;注:大括号里面mkdir vhostscd vhosts/vi nginx.confserver { listen 80;server_name www.test.com;location / { proxy_pass http://www.test.com:8000;}
}
/usr/local/openresty/nginx/sbin/nginx -t
/usr/local/openresty/nginx/sbin/nginxvi /etc/hosts192.168.195.128 www.test.com转载于:https://blog.51cto.com/10158955/2286792