Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- load_module /usr/lib/nginx/modules/ndk_http_module.so;
- load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
- http {
- lua_shared_dict state 12k;
- init_by_lua_block {
- ngx.shared.state:set("suspend", false)
- }
- # rest of your http block
- }
- location = /suspend/MySuperSecretMagicString {
- if ($request_method = PUT) {
- content_by_lua_block {
- ngx.req.read_body()
- content = ngx.req.get_body_data()
- if (content == "go2sleep") then
- ngx.shared.state:set("suspend", true)
- else
- ngx.shared.state:set("suspend", false)
- end
- }
- }
- }
- location / {
- access_by_lua_block {
- while (ngx.shared.state:get("suspend") == true) do
- ngx.sleep(0.2)
- end
- }
- proxy_pass http://my-backend;
- }
- curl -X PUT -d go2sleep http://localhost/suspend/MySuperSecretMagicString
- curl -X PUT -d UnleashTheHounds http://localhost/suspend/MySuperSecretMagicString
Add Comment
Please, Sign In to add comment