February 2018
Beginner to intermediate
348 pages
9h 40m
English
If you already understand how HTTP load balancing works in Nginx, the following example will look spectacularly simple to you. We will configure Nginx to receive MySQL connections and balance them across two backend servers:
stream {
upstream MyGroup {
# use IP address-based distribution
hash $remote_addr;
server 10.0.0.201 weight=2;
server 10.0.0.202;
server 10.0.0.203 backup; # use as backup only
}
server {
# listen on the default MySQL port
listen 3306;
proxy_pass MyGroup; # forward requests to upstream
}
}
That's all there is to it. All directives and options offered by the upstream module are still there, but keep in mind that you won't be able to use HTTP-based variables (such as cookies) to achieve ...
Read now
Unlock full access