当前位置 : 首页 » 文章分类 :  开发  »  OpenResty

OpenResty

OpenResty 就是 Nginx + Lua

中文官网
https://openresty.org/cn/

GitHub
https://github.com/openresty/openresty

Components
https://openresty.org/cn/components.html

lua-nginx-module

openresty/lua-nginx-module
https://github.com/openresty/lua-nginx-module

access_by_lua_block

https://github.com/openresty/lua-nginx-module#access_by_lua_block

syntax: access_by_lua_block { lua-script }
context: http, server, location, location if
phase: access tail

例如,加载 lua 脚本,处理请求,并验证签名

  1. location ~^/api/user/ {
  2. access_by_lua_block {
  3. local req_processor = require("lua/req_processor")
  4. req_processor.set_req_id()
  5. req_processor.set_real_ip()
  6. local sign = require("lua/verify_sign")
  7. sign.verify_sign()
  8. }
  9. proxy_pass http://localhost:8001;
  10. add_header 'Access-Control-Allow-Origin' $corsHost;
  11. proxy_set_header Host $host;
  12. proxy_set_header X-Real-IP $remote_addr;
  13. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  14. }

上一篇 LeetCode.005.LongestPalindromicSubstring 最长回文子串

下一篇 Micrometer

阅读
评论
121
阅读预计1分钟
创建日期 2019-11-20
修改日期 2019-11-20
类别

页面信息

location:
protocol: http:
host: masikkk.com
hostname: masikkk.com
origin: http://masikkk.com
pathname: /article/OpenResty/
href: http://masikkk.com/article/OpenResty/
document:
referrer:
navigator:
platform: Linux x86_64
userAgent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)

评论