# Nginx

**Nginx**（也写作 NGINX）是用于 Web 服务、反向代理、缓存、负载均衡和媒体流传输的开源软件，也可充当电子邮件协议（IMAP、POP3 和 SMTP）的代理服务器，以及 HTTP、TCP 和 UDP 服务器的反向代理和负载均衡器。<sup>[1](https://docs.nginx.com/nginx/)</sup> 它由俄罗斯开发者伊戈尔·瑟索耶夫（Igor Sysoev）创建，他于 2002 年开始编写，并于 2004 年 10 月 4 日公开发布；这一天是第一颗人造卫星斯普特尼克（Sputnik）发射 47 周年。<sup>[2](https://blog.nginx.org/blog/celebrating-20-years-of-nginx)</sup>

| 关键事实 | 详情 |
|---|---|
| 它是什么 | 用于 Web 服务、反向代理、缓存、负载均衡和媒体流传输的开源软件<sup>[1](https://docs.nginx.com/nginx/)</sup> |
| 起源 | 2002 年开始开发；2004 年 10 月 4 日公开发布，选定该日期是为了纪念斯普特尼克发射 47 周年<sup>[2](https://blog.nginx.org/blog/celebrating-20-years-of-nginx)</sup> |
| 公司 | NGINX 公司（NGINX, Inc.）由伊戈尔·瑟索耶夫与联合创始人马克西姆·科诺瓦洛夫（Maxim Konovalov）和安德鲁·阿列克谢耶夫（Andrew Alexeev）于 2011 年成立<sup>[3](https://blog.nginx.org/blog/do-svidaniya-igor-thank-you-for-nginx)</sup> |
| 架构 | 一个读取配置并维护工作进程的主进程，外加一个或多个处理请求的工作进程；工作进程数可随 CPU 核心数调整<sup>[4](https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/)</sup> |
| 负载均衡方法 | 轮询（默认）、最少连接和 IP 哈希<sup>[5](https://nginx.org/en/docs/http/load_balancing.html)</sup> |
| 代理协议 | HTTP、HTTPS、FastCGI、uwsgi、SCGI、memcached 和 gRPC，以及 TCP 和 UDP<sup>[5](https://nginx.org/en/docs/http/load_balancing.html)</sup><sup> • </sup><sup>[1](https://docs.nginx.com/nginx/)</sup> |
| 商业版 | NGINX Plus 增加了最短时间均衡、慢启动和会话保持等企业功能<sup>[6](https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/)</sup> |

## 历史

伊戈尔·瑟索耶夫于 2002 年开始将 Nginx 作为一款全新软件进行开发，此前他在接触过早期 Web 服务器之后，开始试验操作系统的效率机制。<sup>[2](https://blog.nginx.org/blog/celebrating-20-years-of-nginx)</sup> 在俄罗斯和国外数家公司开始使用 NGINX 之后，他于 2004 年 10 月 4 日以宽松许可证将该项目开源。<sup>[3](https://blog.nginx.org/blog/do-svidaniya-igor-thank-you-for-nginx)</sup> 瑟索耶夫把历史性太空任务的关键日期用作其产品的发布里程碑，以此向太空探索致意，这也解释了为何选择斯普特尼克发射周年作为发布日期。<sup>[2](https://blog.nginx.org/blog/celebrating-20-years-of-nginx)</sup>

2011 年，瑟索耶夫与联合创始人马克西姆·科诺瓦洛夫和安德鲁·阿列克谢耶夫共同成立 NGINX 公司，以加快开发。<sup>[3](https://blog.nginx.org/blog/do-svidaniya-igor-thank-you-for-nginx)</sup> 该公司后来被 F5 收购，其产品文档现在同时涵盖 NGINX 开源版和商业版 NGINX Plus。<sup>[7](https://docs.nginx.com/)</sup>

## 架构与性能

许多 Web 服务器和应用服务器采用线程或基于进程的架构，而 NGINX 采用事件驱动架构，使其在现代硬件上能够扩展到数十万个并发连接。<sup>[8](https://blog.nginx.org/blog/inside-nginx-how-we-designed-for-performance-scale)</sup> 运行时，NGINX 有一个主进程和一个或多个工作进程。主进程读取并评估配置文件，并维护工作进程；工作进程负责实际的请求处理，操作系统机制用于在它们之间分发传入连接。启用缓存时，启动阶段还会运行缓存加载进程和缓存管理进程。<sup>[4](https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/)</sup>

工作进程数由 `nginx.conf` 配置文件中的 `worker_processes` 指令设置，可以设为固定数量，也可以配置为根据可用 CPU 核心数自动调整；在四核服务器上，主进程会创建四个工作进程，外加管理磁盘内容缓存的缓存辅助进程。<sup>[4](https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/)</sup><sup> • </sup><sup>[8](https://blog.nginx.org/blog/inside-nginx-how-we-designed-for-performance-scale)</sup> 管理员通过 `nginx` 命令及其 `-s` 参数向主进程发送信号来控制运行中的系统，从而无需停止服务即可重新加载配置。<sup>[4](https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/)</sup>

## 负载均衡

Nginx 被广泛用作 HTTP 负载均衡器，在多个应用服务器之间分发流量，以优化资源利用率、最大化吞吐量、降低延迟并提供容错能力。<sup>[5](https://nginx.org/en/docs/http/load_balancing.html)</sup> 开源版 NGINX 支持三种负载均衡方法：

- **轮询**为默认方法，按顺序将请求分发给各应用服务器。<sup>[5](https://nginx.org/en/docs/http/load_balancing.html)</sup>
- **最少连接**将下一个请求分配给活动连接数最少的服务器。<sup>[5](https://nginx.org/en/docs/http/load_balancing.html)</sup>
- **IP 哈希**使用基于客户端 IP 地址的哈希函数，为下一个请求选择服务器。<sup>[5](https://nginx.org/en/docs/http/load_balancing.html)</sup>

最小配置使用 `upstream` 指令定义一个服务器组，并通过 `proxy_pass` 将请求代理到该组；未指定方法时，适用轮询。<sup>[5](https://nginx.org/en/docs/http/load_balancing.html)</sup> 反向代理实现包括对 HTTP、[HTTPS](https://www.edgepedia.org/zh/https)、FastCGI、uwsgi、SCGI、memcached 和 gRPC 的负载均衡，并为非 HTTP 协议提供专用传递指令，如 `fastcgi_pass` 和 `grpc_pass`，还包括带内（被动）服务器健康检查。<sup>[5](https://nginx.org/en/docs/http/load_balancing.html)</sup>

NGINX 和 NGINX Plus 为 HTTP 和 HTTPS 流量提供第 7 层（应用层）负载均衡，并为 TCP 和 UDP 提供第 4 层（传输层）负载均衡。<sup>[6](https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/)</sup><sup> • </sup><sup>[1](https://docs.nginx.com/nginx/)</sup> 商业版 NGINX Plus 在开源方法之外增加了功能，包括最短时间、慢启动（让恢复的服务器平稳地重新接入）和会话保持（“粘性”会话），后者将客户端的请求路由到同一台上游服务器。<sup>[6](https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/)</sup>

## 在 Web 栈中的角色

除了提供静态内容，NGINX 通常还作为应用服务器之前的反向代理、内容缓存和 API 网关运行；F5 将 NGINX Plus 描述为集负载均衡器、反向代理、Web 服务器、内容缓存和 API 网关于一体的产品。<sup>[1](https://docs.nginx.com/nginx/)</sup><sup> • </sup><sup>[7](https://docs.nginx.com/)</sup> 在 Kubernetes 环境中，NGINX Ingress 控制器通过配置映射公开 TCP 和 UDP 服务，这些配置映射将外部端口映射到命名空间和服务名称。<sup>[9](https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/)</sup>

## 与阿帕奇（Apache）的比较

一种常见的说法是，Nginx 以异步、非阻塞架构处理请求，而阿帕奇使用多处理模块。<sup>[11](https://www.ece.ucf.edu/seniordesign/sp2021su2021/g17/Final_SD1.pdf)</sup> 独立基准测试研究发现，在以 PHP 作为服务器端语言时，随着并发工作负载增加，Nginx 平均用更少时间完成请求，并达到比阿帕奇更高的吞吐量。<sup>[12](https://dspace.lib.uom.gr/bitstream/2159/28598/1/KentrotiAikateriniMsc2023.pdf)</sup>

## 版本发布

NGINX Plus 版本基于 NGINX 开源版构建；2026 年 5 月 13 日发布的第一个长期支持版本 NGINX Plus PLS.37.0.0.1 LTS 基于 NGINX 开源版 1.29.8，并引入了由 LTS 版本和持续发布（CR）版本组成的发布模式，其中只有最新的 CR 仍受支持。<sup>[13](https://docs.nginx.com/nginx/releases/)</sup>

## References

1. [About NGINX, F5 NGINX Documentation](https://docs.nginx.com/nginx/)
2. [Celebrating 20 Years of NGINX, NGINX Community Blog](https://blog.nginx.org/blog/celebrating-20-years-of-nginx)
3. [Do Svidaniya, Igor, and Thank You for NGINX, NGINX Community Blog](https://blog.nginx.org/blog/do-svidaniya-igor-thank-you-for-nginx)
4. [Control NGINX Processes at Runtime, NGINX Documentation](https://docs.nginx.com/nginx/admin-guide/basic-functionality/runtime-control/)
5. [Using nginx as HTTP load balancer, nginx.org documentation](https://nginx.org/en/docs/http/load_balancing.html)
6. [HTTP Load Balancing, NGINX Documentation](https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/)
7. [F5 NGINX Product Documentation](https://docs.nginx.com/)
8. [Inside NGINX: How We Designed for Performance & Scale, NGINX Community Blog](https://blog.nginx.org/blog/inside-nginx-how-we-designed-for-performance-scale)
9. [Exposing TCP and UDP services, Ingress-Nginx Controller documentation](https://kubernetes.github.io/ingress-nginx/user-guide/exposing-tcp-udp-services/)
10. [Apache vs NGINX, IBM Technology (video)](https://www.youtube.com/watch?v=9nyiY-psbMs)
11. [NGINX vs Apache comparison table, UCF Senior Design report](https://www.ece.ucf.edu/seniordesign/sp2021su2021/g17/Final_SD1.pdf)
12. [Inter-web server comparisons, University of Macedonia MSc thesis (2023)](https://dspace.lib.uom.gr/bitstream/2159/28598/1/KentrotiAikateriniMsc2023.pdf)
13. [NGINX Plus Releases, NGINX Documentation](https://docs.nginx.com/nginx/releases/)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Named software products and platforms › Web servers and content platforms

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/nginx

English original: https://www.edgepedia.org/nginx
