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
随机推荐
- cdh-hbase用户无法执行命令
- Django:CSRF(Cross-request forgery)跨站请求伪造
一.CSRF是什么 二.CSRF攻击原理 三.CSRF攻击防范 一.CSRF是什么 CSRF(Cross-site request forgery)跨站请求伪造,也被称为“One Click Atta ...
- 3.Git 命令行操作
1.Git 命令行操作(本地库操作): 1.1. 创建本地库(本地库初始化): 第一步:首先在D盘建了个名为git空文件夹,命令行中cd到这个文件夹: 第二步:通过git init命令把这个目录变成G ...
- 使用VisualGDB和OpenOCD调试STM32L0开发板
本教程主要介绍如何配置VisualGDB和OpenOCD来调试STM32L0开发板的固件,使微控制器进入睡眠模式. 我们将创建一个NUCLEO-L031K6开发板的基本工程,并介绍当CPU进入休眠模式 ...
- python_反射:应用
class User(object): def denglu(self): print('欢迎来到登录页面!') def zhuce(self): print('欢迎来到注册页面!') def you ...
- web-----chrome DevTools工具的常用使用记录
注:1.Chrome浏览器,2.在浏览器页面 右键--->检查,即可看到此页面 跟开发沟通过.他们查看一个页面的性能一般都会使用”检查“来观测.查找对应的数据记录. 设置网络的网速和通过设置某 ...
- The 2019 China Collegiate Programming Contest Harbin Site I. Interesting Permutation
链接: https://codeforces.com/gym/102394/problem/I 题意: DreamGrid has an interesting permutation of 1,2, ...
- parted分区命令
Parted是一个比fdisk更高级的工具,它支持多种分区表格式,包括MS-DOS和GPT.它允许用户创建,删除,调整大小,缩小,移动和复制分区,重新组织磁盘使用,以及将数据复制到新硬盘,但在缩小分区 ...
- Ubuntu 下python开发环境的搭建
一.安装python3 ubuntu自身是安装python2的,例如在ubuntu 16.04中安装的就是python2.7.但我想在python3的环境下进行开发所以就要安装python3.但由于u ...
- python 小数处理
modf() 分别取整数部分和小数部分 math模块函数import mathn = 3.75print(math.modf(n))>>> (0.75, 3.0)n = 3.25pr ...