惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
博客园 - 聂微东
IT之家
IT之家
GbyAI
GbyAI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Y
Y Combinator Blog
博客园 - 【当耐特】
The Cloudflare Blog
宝玉的分享
宝玉的分享
罗磊的独立博客
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
V
Visual Studio Blog
小众软件
小众软件
博客园_首页
Last Week in AI
Last Week in AI
J
Java Code Geeks
V
V2EX
雷峰网
雷峰网
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
腾讯CDC
博客园 - 司徒正美
Engineering at Meta
Engineering at Meta
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
DataBreaches.Net
博客园 - 三生石上(FineUI控件)
MyScale Blog
MyScale Blog
云风的 BLOG
云风的 BLOG
The Register - Security
The Register - Security
M
MIT News - Artificial intelligence
Microsoft Azure Blog
Microsoft Azure Blog
T
The Blog of Author Tim Ferriss
N
Netflix TechBlog - Medium
F
Full Disclosure
B
Blog
H
Help Net Security
C
Check Point Blog
WordPress大学
WordPress大学
人人都是产品经理
人人都是产品经理
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
酷 壳 – CoolShell
酷 壳 – CoolShell
Blog — PlanetScale
Blog — PlanetScale
L
LangChain Blog
P
Proofpoint News Feed
D
Docker
Microsoft Security Blog
Microsoft Security Blog

程序员笔记(huoyijie.cn)

generate new dataset with llm and knowledge graph resume deepseek applications Implement the classic huarongdao game with react Implement the classic tetris game with react Writing admin dashboard template with Nextjs How to AuthN user with OpenLDAP share whiteboard with websocket ocr overview tech notes subscribe topic with sse multi devices github an algorithm used for image text detect an algorithm used for image text detect facial expression recognition technology based on neural network oauth2 mysql store a real time collaborative whiteboard with infinite space How to perform load testing with Grafana k6 fix split of undefined with gitbook theme nodejs http proxy middleware analyze referer of express website writing a CDN origin server with Django a personal lightweight CMS tool writing in Golang profile introduce the post processing introduce the text detect method blockchain for dummies medical applications on ai facial expression recognition study facial expression recognition auth auth with oauth2 auth with jwt chat with sse react chat with websocket react http message signatures infinite whiteboard with socket.io multi factor auth with totp subscribe topic with sse capture screen to gif Golang 经典入门实践教程 · GitBook EFS 加密文件系统 · GitBook 弈杰围棋智能终端 · GitBook 如何把手机触摸屏变成触控板(Touchpad) · GitBook 基于 SOCKET.IO 搭建个人电脑 HTTP 静态服务器代理 · GitBook 三百行代码搭建一个简单的 SOCKS5 代理服务器 · GitBook 微信小程序(蓝牙BLE)远程遥控树莓派小车 · GitBook 语音远程遥控树莓派小车 · GitBook 树莓派的一些使用经验 · GitBook 从零开始制作树莓派小车 · GitBook UDPack 2.0 协议 · GitBook 前言 · GitBook 升级 Ubuntu 到 20.04 LTS 长期维护版本 · GitBook 网站支持 HTTP 2.0 · GitBook 搭建配置邮件服务器 · GitBook 使用 Git 与 Gitbook 创建管理电子书 · GitBook 网站图片视频接入CDN · GitBook a personal lightweight self hosted git server written in Golang 快速搭建CDN回源服务器 · GitBook 基于 Git 搭建代码托管服务器 · GitBook
反向代理服务器实现原理 · GitBook
huoyijie · 2024-05-24 · via 程序员笔记(huoyijie.cn)

反向代理服务器实现原理

本篇文章接上篇 网站支持 HTTP 2.0,那篇文章中提到我对网站进行了升级,以支持 HTTP/2.0。我在博客程序前部署了 nginx 反向代理,通过 nginx 实现 TLS 加密、数据压缩、websocket 转发及 HTTP 2.0 通信。

Internet 上代理这个概念非常流行,随处可见。如同字面意思,代理服务器即指代表真实机器的中间服务器,可以隐藏真实机器的地址和身份,代理服务器作为代表与目标机器建立连接,在真实机器与目标机器之间转发数据。

反向代理是相对正向代理而言的。想要搞清楚反向代理,就必须先了解正向代理。正向代理位于客户端机器前面,比如常见的 HTTP Proxy 或者 Socks Proxy 等。通过在浏览器中设置代理服务器的 IP 地址、端口号、用户名密码等信息,即可通过代理服务器上网。

反向代理位于服务器前面,可以起到隐藏和保护后台 Web 服务器的作用,浏览器等客户端程序不能够直接连接 Web 服务器,无法得知代理服务器后的网络拓扑结构。

常见开源软件

常见的反向代理软件有 Nginx、Apache、Caddy、HAProxy、Squid 等

主要作用

  • 对客户端隐藏服务器(集群)的IP地址
  • 安全:作为应用层防火墙,为网站提供对基于Web的攻击行为(例如DoS/DDoS)的防护,更容易排查恶意软件等
  • 为后端服务器(集群)统一提供加密和SSL加速(如SSL终端代理)
  • 负载均衡,若服务器集群中有负荷较高者,反向代理通过URL重写,根据连线请求从负荷较低者获取与所需相同的资源或备援
  • 对于静态内容及短时间内有大量访问请求的动态内容提供缓存服务
  • 对一些内容进行压缩,以节约带宽或为网络带宽不佳的网络提供服务 减速上传
  • 提供HTTP访问认证

基于反向代理服务器的重要性,我想通过动手实现一个具备基本功能的反向代理服务器 hawkey,来深入了解下其中的原理。在你通过浏览器看本文时,浏览器发出的到 huoyijie.cn 的所有请求都是经过 hawkey 反向代理转发到博客程序的。后文中,我会陆续介绍 hawkey 的主要代码实现。