Created
August 21, 2019 05:21
-
-
Save ducmeit1/5afdc97ca6ffefd2fbe5ec07a4a2577c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream backend { | |
192.168.0.1:8000; #server 1 | |
192.168.0.2:8001; #server 2 | |
balancer_by_lua_block { | |
//write your round robin code here | |
local host, port = picked_server() | |
if not host and not port then | |
ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR | |
ngx.say("no live upstream") | |
ngx.exit(ngx.HTTP_OK) | |
return | |
end | |
local ok, err = balancer.set_current_peer(host, port) | |
if not ok then | |
ngx.status = ngx.HTTP_INTERNAL_SERVER_ERROR | |
ngx.say("failed to set current peer") | |
ngx.exit(ngx.HTTP_OK) | |
return | |
end | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment