Skip to content

Instantly share code, notes, and snippets.

@wilkice
Created December 15, 2021 02:45
Show Gist options
  • Save wilkice/f95a54709b4b60c2e126366f20b81896 to your computer and use it in GitHub Desktop.
Save wilkice/f95a54709b4b60c2e126366f20b81896 to your computer and use it in GitHub Desktop.
[nginx load balance by full client ip] #nginx #linux
   upstream apachereadonly  {
     server 10.10.11.10:8011; 
     server 10.10.11.11:8011; 
     server 10.10.11.12:8011; 
	 hash $remote_addr consistent;
   }

Please note the ip_hash of nginx only cares the first thress parts of client ip, so 10.0.0.1/24 all will go to the same backend server.

https://nginx.org/en/docs/http/ngx_http_upstream_module.html?&_ga=2.21472571.1282218921.1639534616-599670245.1639534616#hash

https://nginx.org/en/docs/http/ngx_http_core_module.html#variables

https://www.nginx.com/products/nginx/load-balancing/#load-balancing-methods

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment