Guest User

Untitled

a guest
Dec 10th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. load_module /usr/lib/nginx/modules/ndk_http_module.so;
  2. load_module /usr/lib/nginx/modules/ngx_http_lua_module.so;
  3.  
  4. http {
  5. lua_shared_dict state 12k;
  6. init_by_lua_block {
  7. ngx.shared.state:set("suspend", false)
  8. }
  9. # rest of your http block
  10. }
  11.  
  12. location = /suspend/MySuperSecretMagicString {
  13. if ($request_method = PUT) {
  14. content_by_lua_block {
  15. ngx.req.read_body()
  16. content = ngx.req.get_body_data()
  17. if (content == "go2sleep") then
  18. ngx.shared.state:set("suspend", true)
  19. else
  20. ngx.shared.state:set("suspend", false)
  21. end
  22. }
  23. }
  24. }
  25.  
  26. location / {
  27. access_by_lua_block {
  28. while (ngx.shared.state:get("suspend") == true) do
  29. ngx.sleep(0.2)
  30. end
  31. }
  32. proxy_pass http://my-backend;
  33. }
  34.  
  35. curl -X PUT -d go2sleep http://localhost/suspend/MySuperSecretMagicString
  36.  
  37. curl -X PUT -d UnleashTheHounds http://localhost/suspend/MySuperSecretMagicString
Add Comment
Please, Sign In to add comment