Coder Social home page Coder Social logo

nginx_conf's Introduction

nginx_conf

nginx.sleep.conf

实现: 接收用户请求后, 扔色子,决定是否处理用户的请求. 如果用户运气不佳, 让用户sleep一段时间

$ curl http://127.0.0.1:8080/sleep
sleep 4s & wake up

$ curl http://127.0.0.1:8080/sleep
sleep 1s & wake up

$ curl http://127.0.0.1:8080/sleep
sleep 3s & wake up

$ curl http://127.0.0.1:8080/sleep
sleep 3s & wake up

$ curl http://127.0.0.1:8080/sleep
sleep 1s & wake up

$ curl http://127.0.0.1:8080/sleep
Good luck

$ curl http://127.0.0.1:8080/sleep
sleep 5s & wake up

$ curl http://127.0.0.1:8080/sleep
sleep 6s & wake up

nginx.shared.conf

实现: 测试lua_shared_dict. 在线修改共享内存中的值

$curl http://127.0.0.1:8080/getone
取出1个, 剩余:4
$curl http://127.0.0.1:8080/getone
取出1个, 剩余:3
$curl http://127.0.0.1:8080/getone
取出1个, 剩余:2
$curl http://127.0.0.1:8080/getone
取出1个, 剩余:1
$curl http://127.0.0.1:8080/getone
取出1个, 剩余:0
$curl http://127.0.0.1:8080/getone
<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>ngx_openresty/1.4.3.3</center>
</body>
</html>
$curl "http://127.0.0.1:8080/add?num=10"
补充后,当前苹果数为:10
$curl http://127.0.0.1:8080/getone
取出1个, 剩余:9
$

p.s.

提交工程:

git push origin master

nginx_conf's People

Contributors

cf2012 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.