Skip to content

相同的 URI 转发到同一台上游服务器(URI 指端口号后的内容)

适用于

  • 不支持 cookie 的情况

  • 资源不平均分配

nginx
worker_processes  1;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    upstream httpds {
        # 开启 url 负载均衡
        hash $request_uri;
        server 192.168.44.102;
        server 192.168.44.103;
    }

    server {
        listen       80;
        server_name  www.rainx.top;

        location / {
            proxy_pass http://httpds;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}