nginx負載均衡策略url_hash配置方法

參考文章:nginx

https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/
根據路徑,進行一致性hash,具體的配置方法ide

upstream backend {
    hash $request_uri consistent;
    server backend1.example.com;
    server backend2.example.com;
}

須要注意的是:順序不能錯,不然會報錯ui

nginx: [warn] load balancing method redefined in /etc/nginx/conf.d/upstream.conf:5

https://ma.ttias.be/nginx-nginx-warn-load-balancing-method-redefined/code

相關文章
相關標籤/搜索