Files
nexus/wiki/concepts/反向代理.md

43 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "反向代理"
type: concept
tags: [networking, infrastructure, caddy, nginx]
---
## 定义
反向代理位于客户端和后端服务器之间,客户端请求先到达反向代理服务器,由反向代理服务器转发请求到内部网络的后端真实服务器。
## 核心功能
- **隐藏后端结构**:客户端只知道反向代理地址,不知道内部服务器 IP
- **SSL/TLS 终止**:反向代理统一处理 HTTPS加密解密在内网外完成
- **负载均衡**:将请求分发到多台后端服务器
- **自动 HTTPS**Caddy 等工具可自动申请和续期 SSL 证书
## 在家庭基础设施中的应用
### CaddyVPS1
Caddy 作为 *.ishenwei.online 的 HTTPS 反向代理:
- 自动申请 Let's Encrypt 证书
- 根据域名路由到对应的 FRP 映射端口
### nginx-proxy-managerUbuntu1
Ubuntu1 上的反向代理管理界面,支持 Web UI 管理域名和 SSL 证书。
## 与 FRP 的关系
- [[FRP内网穿透]] 负责将内网端口映射到公网 VPS 端口
- 反向代理建立在 FRP 映射的端口上,提供 HTTPS 层
- FRP 负责 L4TCP层穿透反向代理负责 L7HTTP/HTTPS层路由
## Caddy vs nginx
| 特性 | Caddy | nginx |
|------|-------|-------|
| 自动 HTTPS | ✅ | ❌(需手动配置) |
| 配置文件语法 | 简洁 | 复杂 |
| Web 管理界面 | 无(原生) | nginx-proxy-manager 可提供 |
## Aliases
- Reverse Proxy
- Caddy
- nginx-proxy-manager
- HTTPS 反向代理