

Nginx代理配置只允许指定IP访问
source link: https://blog.51cto.com/u_15430445/5996775
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Nginx代理配置只允许指定IP访问
精选 原创在使用Nginx时,有时只想要指定的IP进行访问,其余IP都需要禁止,今天就来说一下,Nginx如何配置允许、禁止指定Ip访问
index index.jsp;
proxy_next_upstream http_500 http_502 http_503 http_504 error timeout invalid_header;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
deny 192.168.1.1;
allow 127.0.0.0/50;
allow 173.56.0.0/25;
allow 132.16.0.0/25;
allow 12.170.0.0/25;
deny all;
}
注意事项:
1. deny
一定要加一个ip,否则直接跳转到403,不往下执行了;如果403默认页是同一域名下,会造成死循环访问;
2. allow的ip段
从允许访问的段位从小到大排列,如:127.0.0.0/50
下面才能是:12.170.0.0/25
24表示子网掩码:255.255.255.0
16表示子网掩码:255.255.0.0
8表示子网掩码:255.0.0.0
3. deny all;结尾
表示除了上面allow的其他都禁止
Recommend
-
95
续:nginx安装配置开启nginx请求日志同时解开http模块如下部分注释log_formatmain'$remote_addr-$remote_user[$time_local]"$request"''$status$body_bytes_sent"$http_referer"''"$http_user_agent""$http_x_forwarded_for"';access_loglogs
-
30
Nginx配置多端口多域名访问 Nov 18th, 2019 | Comments
-
13
https://segmentfault.com/a/1190000019563509 NGINX解决HTTPS代理的方式都属于透传(隧道)模式,即不解密不感知上层流量。具体的方式有如下7层和4层的两类解决方案。 HTTP C...
-
5
11 April 2020 / 开发笔记 Nginx 配置允许跨域访问 CORS 原文地址: https://en...
-
14
V2EX › 程序员 请教通过 HTTP 代理访问配置有 Cloudflare CDN 的网站 gxever · 20 小时 5...
-
7
配置v2ray+nginx+ws访问国际网络 发表于...
-
5
nginx只允许域名访问,禁止ip访问 背景:为什么要禁止ip访问页面呢?这样做是为了避免其他人把未备案的域名解析到自己的服务器IP,而...
-
5
什么是反向代理?Nginx反向代理如何配置?-51CTO.COM 什么是反向代理?Nginx反向代理如何配置? 作者:wljslmz 2022-07-01 07:33:24 在开始本文前,请先保证你的服务器已经安装好ngin...
-
8
故障现象: 1、被代理机器单独访问正常; 2、通过集群访问,连接不带端口,无法访问(502); 配置如下:...
-
6
配置 Nginx 通过代理访问反代目标(B站代理解析) · GitHub 配置 Nginx 通过代理访问反代目标(B站代理解析) 众所周知,有些服务存在着地区限制,我们可以通过在服务所属地区搭...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK