Nginx
一句话解释
Nginx 是 popular 打开-源 web 服务器, reverse proxy, and 加载 balancer known for 高性能 and 低 resource usage.
用大白话说
Nginx (pronounced "engine-x") is one of the most popular web servers in the world. It can serve as a web server, reverse proxy, load balancer, and HTTP cache.
Nginx 是known for being fast and efficient。 It uses an event-driven, asynchronous architecture that lets it handle thousands of concurrent connections with very little memory. This makes it ideal for high-traffic sites.
In a DevOps context, Nginx is often used as an Ingress Controller in Kubernetes — it receives external HTTP traffic and routes it to the right Service based on Ingress rules. It is also commonly used as a reverse proxy in front of application servers.
示例
server {
listen 80;
server_name api.example.com;
location / {
proxy_pass http://backend:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}这个 Nginx 配置 listens on port 80 and proxies 所有请求到 backend 服务器 on port 3000.
工作原理
- Nginx listens on configured ports (e.g., 80, 443).
- When a request arrives, it matches a server block by host and path.
- It serves static files directly or proxies to a backend server.
- It can also handle TLS, caching, and load balancing.
常见混淆
容易混淆的对象: Apache
关键区别: Nginx uses 事件-driven 架构 (handles 许多连接每 thread); Apache traditionally uses 处理/thread 每连接, using 更多 memory under 加载.
相关术语
解读错误信息
用大白话解释常见错误——什么意思、为什么发生、如何修复。