Nginx设置黑名单
date: 2019-07-04 14:35:56
author: headsen chen
notice: 个人原创
1,在分域名下面设置:
[root@pro-nginx:/usr/local/openresty/nginx/conf/sites]$cat www.ceshi.com.conf
geo $remote_addr $black {
121.35.3.0/24 1;
121.35.2.0/24 1;
121.35.1.0/24 1;
121.35.0.0/24 1;
112.97.63.0/24 1;
112.97.50.0/24 1;
211.101.18.214 1;
124.232.148.90 1;
118.193.154.149 1;
140.240.23.99 1;
}
server {
listen 80;
listen 443 ssl;
include ceshi-ssl-ev.conf;
server_name www.ceshi.com;
2,在分域名下面设置(设置在匹配项下面的):
location / {
deny 192.168.1.1;
allow 192.168.1.0/24;
allow 10.1.1.0/16;
allow 2001:0db8::/32;
deny all;
proxy_pass http://10.1.1.1:2000;
}
3,在Nginx的总入口上配置访问ip限制,只有在白名单里面的才可以访问。
[root@beta-usrv01:/usr/local/openresty/nginx/conf]$cat nginx.conf
user fmservice;
worker_processes auto;
events {
worker_connections 102400;
} http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server_names_hash_bucket_size 128;
log_format main '$remote_addr [$time_local] "$host" "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$request_time:$upstream_response_time" $upstream_addr "$upstream_status" "$upstream_cache_status"';
client_max_body_size 50m;
gzip on;
gzip_types text/plain application/javascript application/x-javascript text/xml text/css image/png image/jpg image/gif image/jpeg;
gzip_vary off;
geo $remote_addr $whitelist {
default 0;
127.0.0.1 1;
172.0.0.0/8 1;
10.0.0.0/8 1;
119.189.0.0/16 1;
113.169.0.0/16 1;
139.108.102.77 1;
112.174.61.155 1;
120.178.139.70 1;
......
} map $http_x_app_info $appheader {
default "";
}
} 也可以分开写:
[root@metabase:/usr/local/openresty/nginx/conf]$cat nginx.conf
worker_processes 1;
events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; log_format main '$remote_addr [$time_local] "$host" "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'"$request_time:$upstream_response_time" $upstream_addr "$upstream_status" "$upstream_cache_status"'; access_log logs/access.log main;
error_log logs/error.log;
sendfile on;
keepalive_timeout 65;
include whiteiplist.conf;
server {
listen 80;
server_name aaaa.bbbbbbl.com default;
access_log /var/log/nginx/aaaaa.bbbbbbl.com.log main; if ( $whitelist != 1 ) {
return 403;
#set $fasdbfad 1;
}
[root@metabase:/usr/local/openresty/nginx/conf]$cat whiteiplist.conf
geo $remote_addr $whitelist {
default 0;
101.232.131.102 1;
124.42.150.166 1;
117.136.40.216 1;
}
Nginx设置黑名单的更多相关文章
- Nginx设置线程数为整机内核数的俩倍!
Nginx设置线程数为整机内核数的俩倍!
- nginx设置不使用缓存 add_header Cache-Control no-cache
nginx设置不使用缓存 server { listen 443; #域名 server_name www.dev.163.com; #字符集 charset utf-8; ssl on; ssl_c ...
- nginx设置SSL反向代理
Nginx的反向代理通常用来映射内网中提供的Apache.IIS.Lighttpd服务,以实现负载均衡:同时,由于动态服务程序运行在内网,服务器的整体安全性也有所提高,那么怎样用nginx设置SSL的 ...
- 给postfix设置黑名单
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- nginx 设置进程title
刚好看到nginx设置进程title的源码,因此做一些总结. linux进程实际是以argv[0]处的值来作为进程的title的,因此若需要修改进程的title只需要修改argv[0]处的值即可. 简 ...
- Nginx设置Https反向代理,指向Docker Gitlab11.3.9 Https服务
目录 目录 1.GitLab11.3.9的安装 2.域名在阿里云托管,申请免费的1年证书 3.Gitlab 的 https 配置 4.Nginx 配置 https,反向代理指向 Gitlab 配置 目 ...
- Nginx设置网站维护页面
网站升级需要停服,可以在Nginx设置静态页面设置强制跳转 修改nginx配置文件nginx.conf http { sendfile on; keepalive_timeout 65; server ...
- Nginx 设置临时维护页面
Nginx 设置临时维护页面 http://www.myexception.cn/open-source/1753957.html http://blog.justwd.net/snippets/ng ...
- nginx 设置默认虚拟 host
nginx 设置默认虚拟 host listren 80 default_server
随机推荐
- Dism++备份还原系统
使用dism++备份和还原需要下载该工具,并选择与系统对应的Dism++x64或Dism++x32运行进行操作. Dism++网络下载地址:http://www.chuyu.me/zh-Hans/in ...
- 一份数据分析学习清单.xls
今天给大家整理一份数据分析的学习清单,打算了解学习这方面的同学可以看看,基本上大的需要学习的点都有涉及:具体细节知识的学习建议大家亲自去动手制作思维导图,自己动手梳理知识脉络. 上期入口:18个堪称神 ...
- python-----opencv图像边界扩充
在对图片进行卷积处理的时候,如果卷积模版(卷积内核)过大,且不对原图的边界进行扩充,会导致处理之后得到的图片尺寸变的很小,也就是严重失真. 而扩充边界有多种方法,本文就介绍一下这些填充方法. 这是原始 ...
- 日期时间格式化 SimpleDateFormat与DateTimeFormatter
原文:https://www.jianshu.com/p/b212afa16f1f 1.SimpleDateFormat为什么不是线程安全的? 如果我们把SimpleDateFormat定义成stat ...
- python函数名的应用、闭包和迭代器
一.函数名的应用(第一类对象) 函数名是一个变量,但它是一个特殊的变量,与括号配合可以执行函数变量. 1.函数名的内存地址 def func(): print("哈哈") prin ...
- [转]对于BIO/NIO/AIO,你还只停留在烧开水的水平吗
原文:https://www.javazhiyin.com/40106.html https://coding.imooc.com/class/381.html ------------------- ...
- eclipse中JDK环境的搭建
现在就可以用记事本开发java程序了,但是eclipse是一款java开发不可缺少的IDE,并且安装简单,下面说一下步骤,首先下载eclipse, 官网下载链接:http://www.eclipse. ...
- Java原子类--AtomicLongFieldUpdater
转载请注明出处:http://www.cnblogs.com/skywang12345/p/3514623.html AtomicLongFieldUpdater介绍和函数列表 AtomicLongF ...
- JavaScript事件——拖拉事件
拖拉事件的种类 拖拉(drag)指的是,用户在某个对象上按下鼠标键不放,拖动它到另一个位置,然后释放鼠标键,将该对象放在那里. 具体的api可查看 拖拽变色demo <div draggable ...
- STM32 HAL库 UART 串口读写功能笔记
https://www.cnblogs.com/Mysterious/p/4804188.html STM32L0 HAL库 UART 串口读写功能 串口发送功能: uint8_t TxData[10 ...