配合server_name _ 可以匹配所有的域名,在设置default server 可以轻松屏蔽一些非域名访问的请求。

配置如下

server {
listen 80 default_server;
server_name _ ;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
error_page 404 = /50x.html; access_log /var/log/nginx/other.log;
}
}

  关键是default_server 在设在listen 同一行。

nginx default server的更多相关文章

  1. Nginx httpS server配置

    Nginx httpS 配置 配置同时支持http和httpS协议: server { listen ; #backlog:每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包 ...

  2. NGINX Web Server Nginx web server

    原文地址:http://nginx.com/resources/admin-guide/web-server/ NGINX Web Server Nginx web server This secti ...

  3. nginx检查报错:nginx: [emerg] "server" directive is not allowed here in

    想检查一个配置文件是否正确,-c 指定之后发现有报错,如下: [root@op-2:~# nginx -t -c /etc/nginx/conf.d/default.conf nginx: [emer ...

  4. nginx多server配置记录

    直接在配置文件(/etc/nginx/nginx.conf)中添加如下代码: server { listen 8080; server_name 192.168.100.174:8080; root ...

  5. nginx: [emerg] BIO_new_file("/etc/nginx/ssl_key/server.crt") failed (SSL: error:02001002:syste

    Centos 7.5 nginx+web集群配置https报错 报错信息: [root@lb01 conf.d]# nginx -tnginx: [emerg] BIO_new_file(" ...

  6. 阿里云centOS7.4 nginx: [emerg] "server" directive is not allowed here in /etc/nginx/vhost/xxxxxx.conf:2

    里云centOS7.4配置多个站点遇到的问题nginx: [emerg] "server" directive is not allowed here in /etc/nginx/ ...

  7. nginx下面server配置

    haomeiv配置 log_format www.haomeiv.com '$remote_addr - $remote_user [$time_local] "$request" ...

  8. linux+asp.net core+nginx+sql server

    Linux Disibutaion:Ubuntu 16.04.1 LTS Web Server:Nginx.Kestrel 安装.net core sudo sh -c 'echo "deb ...

  9. 利用raspberry pi搭建typecho笔记(一) nginx PHP server quick start

    前言 因为一直对linux学习很有兴趣,就拿手头的树莓派做了实验,搭建一个简易的php服务器用来跑typecho. 但是过程却是异乎寻常的艰辛,几乎每一步能卡住得地方都卡住了.而且typecho的资料 ...

随机推荐

  1. curl发送多维数组

    //通过curl模拟post的请求: function SendDataByCurl($url,$data=array()){ //对空格进行转义 $url = str_replace(' ','+' ...

  2. Netty源码分析之ChannelPipeline—异常事件的传播

    ChannelHandler中异常的获取与处理是通过继承重写exceptionCaught方法来实现的,本篇文章我们对ChannelPipeline中exceptionCaught异常事件的传播进行梳 ...

  3. QString 转换成 wchar 的一个小陷阱

    QString::toWCharArray(wchar_t * array) 其中 wchar_t * array 除了要分配内存之外,必须用 wmemset 初始化. 环境是 Visual Stud ...

  4. mac OS 配置Apache服务器

    Mac自带了Apache环境 查看Apache版本 sudo apachectl -v 在终端输入:sudo apachectl start 在浏览器输入"http://localhost& ...

  5. js的call方法

    obj1.method.call(obj2,arg1,arg2,arg3...) call方法的作用就是 把obj1的方法放到obj2对象上使用 arg1,arg2....是参数,传给mehtod的哟 ...

  6. Android Room SQLite持久层框架

    原文链接 前言 Android中提供了SQLite数据库进行数据的持久化 ,并提供了对应API访问数据库,而Room框架提供了SQLite数据访问抽象层,为高效的数据库访问层带来便捷 APP可以缓存用 ...

  7. POJ 2955 区间DP必看的括号匹配问题,经典例题

    Brackets Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14226 Accepted: 7476 Description ...

  8. CodeForces - 262C 贪心

    Maxim always goes to the supermarket on Sundays. Today the supermarket has a special offer of discou ...

  9. DP 60题 -2 HDU1025 Constructing Roads In JGShining's Kingdom

    Problem Description JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which ...

  10. IP 基础知识全家桶,45 张图一套带走

    前言 前段时间,有读者希望我写一篇关于 IP 分类地址.子网划分等的文章,他反馈常常混淆,摸不着头脑. 那么,说来就来!而且要盘就盘全一点,顺便挑战下小林的图解功力,所以就来个 IP 基础知识全家桶. ...