Nginx Lua in Action cover

Nginx Lua in Action

Rating 2.3
Word count
509 words
Chapters
34
Series
HZ Books · In Action Series
ISBN
9787111590293

Tags

Summary

Nginx Lua in Action is a hands-on technical book by Li Mingjiang, published by China Machine Press in March 2018, with the parallel English title Nginx Lua in Action. Taking "building application systems with Lua on Nginx" as its through line, the book strings together servers, scripting language, configuration mechanisms, common components, and a development reference into a single learning path: it first covers Nginx installation and configure parameters, then adds basic operations for MySQL, Redis, PostgreSQL, Memcached, MongoDB, and OpenResty, followed by Nginx's core technologies and workflow alongside Lua syntax and standard libraries. Part Three moves into development practice, covering the JSON data interchange format, methods and directives for configuring nginx.conf, and the implementation mechanisms of ngx_lua across processing phases such as init, rewrite, access, content, header_filter, body_filter, and log. Part Four devotes more than ten chapters to operations for Redis, MySQL, Memcached, PostgreSQL, and MongoDB, as well as usage of libraries including bit, lfs, resty.http, lcurl, FFI, cjson, lua-resty-template, and WebSocket, and provides two examples: a private TCP server and a WebSocket access server. The final two chapters are quick-reference manuals for ngx_lua_module configuration directives and the ngx_lua API. The book runs about 509,000 characters over 565 pages and works well as a desk reference for both getting started and looking things up.

Editor's review

这本书的价值不在“讲得深”,而在“讲得全、能查”。市面上 Nginx 的书多讲配置与调优,讲 Lua 扩展的又常止步于 OpenResty 的入门示例;本书则把 Nginx 安装、数据库与缓存组件的起停、Lua 语法、nginx.conf 结构、请求处理各阶段、二十多个常用库一路铺开,最后两章直接把配置指令和 API 做成速查手册。作者李明江有二十余年研发经历,长期做安防与视频监控平台,书中实例带有明显的工程落地色彩,TCP 私有服务器和 WebSocket 接入服务器两个案例尤其能帮助读者理解从协议接入到 Lua 处理的完整链路。它更像一本“体系化的工具书”:第一次接触 ngx_lua 的人可以顺着章节读通全局,有经验的人可以在需要时翻第 27、28 章查指令。需要提醒的是,本书以官方文档与组件用法整理为主,深度有限,想要钻研源码与高性能调优的读者,应把它当起点而非终点。

Who it's for

A good fit for

  • 已会写 Nginx 配置、想用 Lua 扩展业务逻辑的后端开发者
  • 负责 OpenResty 或网关、接入层开发与维护的工程师
  • 需要快速查阅 ngx_lua 配置指令与 API 的运维与研发人员
  • 有 C++、Java 等语言基础,想系统补齐 Nginx + Lua 技能栈的转型者

Not a good fit for

  • 希望深入 Nginx 源码、事件模型底层实现的高级读者
  • 零编程经验、尚不了解 HTTP 与 Linux 基本操作的纯新手

Reading tips

  1. 把第 27、28 章当工具手册,其余章节按“基础—Lua—机制—实战”顺序通读一遍即可建立地图。
  2. 边读边搭一台虚拟机或容器,按书中步骤装 Nginx、Redis、MySQL,把示例代码逐条跑通。
  3. 重点吃透第 10 章的处理阶段划分,理解 content_by_lua 等指令分别挂在请求生命周期的哪个环节。
  4. 读完 TCP 与 WebSocket 两个实例后,用同样的结构改写一个自己的小服务,比重复抄代码更有收获。

About the publisher

China Machine Press China · Founded in 1950

In addition to science and technology and professional publishing, the books in our catalog from China Machine Press also reflect a sustained focus on psychology, computing, management, finance and economics, and social sciences. In psychology, the catalog includes works by C. G. Jung and introductions to analytical psychology, as well as applied topics such as stress and health, and addiction and healing. In computing, it features Structure and Interpretation of Computer Programs (JavaScript Edition). Management and finance titles include Administrative Behavior (4th Edition), The Price of Inequality (Collector's Edition), and This Time Is Different: Eight Centuries of Financial Folly (Commemorative Edition). In the philosophy and history of science, there is The Worldview: The Third Edition. Relevant authors include C. G. Jung, William McGuire, Sonu Shamdasani, and Gabor Maté. Public information is limited; the above summarizes the publisher's profile based solely on the books in our catalog.

Contents

  1. Preface
  2. Part One: Nginx Operations Fundamentals
  3. Chapter 1: Nginx as an Efficient Server
  4. Chapter 2: Basic Database Operations
  5. Chapter 3: OpenResty
  6. Chapter 4: Nginx Core Technologies
  7. Chapter 5: How Nginx Works
  8. Part Two: The Lua Scripting Language
  9. Chapter 6: Lua Tutorial
  10. Chapter 7: Lua Standard Libraries
  11. Part Three: Nginx Development Techniques
  12. Chapter 8: JSON Data Interchange Format
  13. Chapter 9: Configuring the nginx.conf File
  14. Chapter 10: Lua Implementation Mechanisms Under Nginx
  15. Part Four: Nginx Lua Development in Practice
  16. Chapter 11: Redis Operations
  17. Chapter 12: MySQL Operations
  18. Chapter 13: Memcached Operations
  19. Chapter 14: PostgreSQL Operations
  20. Chapter 15: MongoDB Operations
  21. Chapter 16: Using the bit Library
  22. Chapter 17: Using the lfs Library
  23. Chapter 18: Using the resty.http Library
  24. Chapter 19: Using the lcurl Library
  25. Chapter 20: Extending C Libraries with FFI
  26. Chapter 21: Using the cjson Library
  27. Chapter 22: Using the lua-resty-template Class
  28. Chapter 23: Using WebSocket
  29. Chapter 24: A Private TCP Server Example
  30. Chapter 25: Building a WebSocket Access Server in Practice
  31. Chapter 26: A Brief Overview of Nginx Applications
  32. Part Five: Development Reference
  33. Chapter 27: A Detailed Guide to ngx_lua_module Configuration Directives
  34. Chapter 28: A Detailed Guide to the ngx_lua API

FAQ

这本书是讲 OpenResty 还是原生 Nginx?
两者都涉及。全书以 Nginx 为核心,第 3 章专门介绍 OpenResty 的组成、安装与配置,后续的 ngx_lua 模块、resty.http、lua-resty-template 等内容基本都属于 OpenResty 生态,读者用 OpenResty 打包环境实践会更省事。
零基础能直接读吗?
可以读,但不算轻松。书中第 1 章讲安装与 configure 参数,第 6 章讲 Lua 语法,起点并不高;不过它默认读者懂 Linux 命令行和 HTTP 基础,完全没有编程经验的人需要先补这两块。
第 27、28 章的内容和官方文档有何不同?
内容框架来自 ngx_lua_module 的配置指令与 API 函数,属于整理归纳性质,与官方文档高度重叠。它的好处是中文、成体系、便于离线翻阅;但版本更新与细节以官方文档为准,遇到行为差异要以官方说明为最终依据。
书中的示例代码能直接用于生产环境吗?
示例更偏教学演示,用于理解流程与写法。生产环境还需补充错误处理、超时与重试、连接池配置、日志与监控等,并注意书中基于 2018 年前后的组件版本,实际部署前应先核对当前版本的接口变化。
作者的背景可信吗?
据出版方与图书馆书目介绍,李明江是资深软件开发专家、安防领域技术专家,有超过二十年研发经验,曾参与南方电网广州亚运会安保系统、中国电信全球眼规范等项目,在 Nginx 与 Lua 开发方面有较多工程实践。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category