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

推荐订阅源

S
Schneier on Security
L
LangChain Blog
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
M
MIT News - Artificial intelligence
月光博客
月光博客
云风的 BLOG
云风的 BLOG
MongoDB | Blog
MongoDB | Blog
量子位
AWS News Blog
AWS News Blog
Jina AI
Jina AI
Webroot Blog
Webroot Blog
L
Lohrmann on Cybersecurity
Cisco Talos Blog
Cisco Talos Blog
Latest news
Latest news
Y
Y Combinator Blog
The GitHub Blog
The GitHub Blog
NISL@THU
NISL@THU
The Register - Security
The Register - Security
美团技术团队
博客园 - 三生石上(FineUI控件)
I
Intezer
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
N
Netflix TechBlog - Medium
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
The Exploit Database - CXSecurity.com
C
Cisco Blogs
Attack and Defense Labs
Attack and Defense Labs
S
Securelist
Know Your Adversary
Know Your Adversary
MyScale Blog
MyScale Blog
C
CERT Recently Published Vulnerability Notes
D
Darknet – Hacking Tools, Hacker News & Cyber Security
U
Unit 42
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
雷峰网
雷峰网
B
Blog
P
Privacy International News Feed
W
WeLiveSecurity
T
Threatpost
P
Palo Alto Networks Blog
O
OpenAI News
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
博客园_首页
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
K
Kaspersky official blog
Recent Announcements
Recent Announcements
A
About on SuperTechFans
B
Blog RSS Feed

博客园 - 散尽浮华

Rancher 证书到期问题处理手册 Rancher部署并导入K8S集群 K8S集群灾备环境部署 K8S容器环境下GitLab-CI和GItLab Runner 部署记录 K8S持久化存储PV、PVC笔记 K8S部署ES集群 - 运维笔记 容器和镜像转化、迁移方式 - 运维小结 K8S部署RabbitMQ集群 (镜像模式) - 部署笔记 Pod滚动重启方法 - 运维笔记 Node节点禁止调度(平滑维护)方式- cordon,drain,delete K8S中NodePort端口范围修改 Centos7.4升级到Centos7.7 K8S部署Redis Cluster集群(三主三从模式) - 部署笔记 K8S部署Nacos集群 - 部署笔记 K8S部署Kafka界面管理工具(kafkamanager) K8S部署Kafka集群 - 部署笔记 K8S部署RocketMQ集群(双主双从+同步模式) - 部署笔记 Nginx流量拷贝 - 运维笔记 Nginx基于站点目录和文件的URL访问控制 - 配置笔记
Nginx禁止ip访问或非法域名访问 - 配置笔记
散尽浮华 · 2020-11-18 · via 博客园 - 散尽浮华

在生产环境中,为了网站的安全访问,需要Nginx禁止一些非法访问,如恶意域名解析,直接使用IP访问网站。下面记录一些常用的配置示例:

1)禁止IP访问
如果没有匹配上server name就会找default默认,返回501错误。

server {
   listen 80 default_server;
   server_name _;
   return 501;
}

2)通过301跳转到主页

server {
  listen 80 default_server;
  server_name _;
  rewrite ^(.*) http://www.kevin.com/$1 permanent;
} 

3)凡是请求kevin.bao.com 都跳转到后面域名grace.ru.com上。(需要放到server配置里)

    if ($host ~ '^kevin.bao.com'){
         return 301 https://grace.ru.com$request_uri;
       }