网站首页 > 博客文章 正文
nginx 正向透明代理 安全方面的一些限制
对于代理而已,有时候可能还不够安全,而且这个是基于4层的,所以想要在http上,或者所谓的http头上做限制还是比较难实现了。所以变通一个map实现:
TCP has no concept of server names, so this is not possible. It only works
in HTTP because the client sends the hostname it is trying to access as
TCP没有服务器名称的概念,所以这是不可能的。它只在HTTP中工作,因为客户端发送它试图访问的主机名作为请求的一部分,允许nginx将其与特定的服务器块匹配。
part of the request, allowing nginx to match it to a specific server block.
现在的需求是,限制进入L4的域名比如仅仅是www.baidu.com其他域名进来也不转发。
stream {
resolver 114.114.114.114;
server {
listen 443;
ssl_preread on;
proxy_connect_timeout 5s;
proxy_pass $ssl_preread_server_name:$server_port;
allow 192.168.128.0/17;
deny all;
}
}
如上所示,现在仅仅能在allow这里做部分限制。当如如果是Linux主机话的,还可以在
iptables中做很多限制。但如果我的Nginx L4是一个Pod,那限制的难度就增加了。变通实现,比如我现在仅仅允许某个域名能走这个L4的透明代理
stream {
resolver 114.114.114.114;
map $ssl_preread_server_name $name {
www.baidu.com backend;
}
upstream backend {
server www.baidu.com:443;
}
server {
listen 443;
ssl_preread on;
proxy_connect_timeout 5s;
#proxy_pass $ssl_preread_server_name:$server_port;
proxy_pass $name;
allow 192.168.128.0/17;
deny all;
}
}
其实就是变相的upstream 仅仅允许对应的域名能够upstream backend
其他的域名不做处理。
- 上一篇: 12《Nginx 入门教程》Nginx负载均衡(上)
- 下一篇: http Stream 流
猜你喜欢
- 2024-12-19 nginx配置tcp代理
- 2024-12-19 Prometheus快速监控Nginx
- 2024-12-19 Nginx搭建RTMP推拉流服务器
- 2024-12-19 nginx入门——nginx访问日志(六)
- 2024-12-19 nginx配置http和tcp服务负载均衡
- 2024-12-19 解决php因为输出内容太短无法流式(Stream)输出问题
- 2024-12-19 利用Nginx正向代理实现局域网电脑访问外网
- 2024-12-19 使用 Nginx 实现推流搭建自己的流媒体服务器
- 2024-12-19 Nginx模块开发:从源码剖析整个Nginx框架
- 2024-12-19 Linux下如何用nginx+ffmpeg搭建流媒体服务器
你 发表评论:
欢迎- 最近发表
-
- 给3D Slicer添加Python第三方插件库
- Python自动化——pytest常用插件详解
- Pycharm下安装MicroPython Tools插件(ESP32开发板)
- IntelliJ IDEA 2025.1.3 发布(idea 2020)
- IDEA+Continue插件+DeepSeek:开发者效率飙升的「三体组合」!
- Cursor:提升Python开发效率的必备IDE及插件安装指南
- 日本旅行时想借厕所、买香烟怎么办?便利商店里能解决大问题!
- 11天!日本史上最长黄金周来了!旅游万金句总结!
- 北川景子&DAIGO缘定1.11 召开记者会宣布结婚
- PIKO‘PPAP’ 洗脑歌登上美国告示牌
- 标签列表
-
- ifneq (61)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)