Name-based virtual servers

server {listen      80;server_name example.org www.example.org;...
}server {listen      80;server_name example.net www.example.net;...
}server {listen      80;server_name example.com www.example.com;...
}

nginx获得request的header中的"Host",来决定哪个"server"来处理.如果没有匹配成功则会使用默认的server;在上面的代码中,第一个就是默认的server,也可以添加default_server来指定

server {listen      80 default_server; # 第一个server默认有此参数server_name example.net www.example.net;...
}

How to prevent processing requests with undefined server names
如果requests没有"Host",将不会被通过,可以用以下代码处理:

server {listen      80;server_name ""; # 对应没有hostreturn      444;
}

Mixed name-based and IP-based virtual servers

server {listen      192.168.1.1:80;server_name example.org www.example.org;...
}server {listen      192.168.1.1:80;server_name example.net www.example.net;...
}server {listen      192.168.1.2:80;server_name example.com www.example.com;...
}

In this configuration, nginx first tests the IP address and port of the request against the listen directives of the server blocks. It then tests the “Host” header field of the request against the server_name entries of the server blocks that matched the IP address and port. If the server name is not found, the request will be processed by the default server. For example, a request for www.example.com received on the 192.168.1.1:80 port will be handled by the default server of the 192.168.1.1:80 port, i.e., by the first server, since there is no www.example.com defined for this port.

参考:
http://nginx.org/en/docs/http/request_processing.html

nginx How nginx processes a request相关推荐

  1. Nginx配置-SSLThe plain HTTP request was sent to HTTPS port解决

    Nginx配置-SSL 准备ssl证书 配置示例 配置强制http访问也走https 准备ssl证书 可以直接从阿里云控制台申请免费证书(每年20个,每个有一年有效期) 也可以使用自签证书,Nginx ...

  2. nginx:nginx学习

    一.nginx 二.linux安装nginx 三.nginx常用命令 五.nginx配置实例 1  反向代理-1 2  反向代理-2 3 负载均衡 4 动静分离 5 高可用 六 nginx原理 一.n ...

  3. Nginx服务器--Nginx服务器的使用笔记

    1.Nginx简介 Nginx("engine x") 一个具有高性能的[HTTP]和[反向代理]的[WEB服务器],同时它也是一个[POP3/SMTP/IMAP代理服务器],由伊 ...

  4. 从零开始的Nginx [ 8 ] --- nginx 的性能优化:ab接口压力测试工具,tomcat企业运维,WEB站点部署,项目上线

    文章目录 nginx 性能优化 1.当前系统结构瓶颈 2.了解业务模式 3.性能与安全 4.系统与nginx性能优化 1.文件句柄 2.设置方式 3.系统全局性修该和用户局部性修改 4.进程局部性修改 ...

  5. Nginx配置文件nginx.conf中文详解(转)

    ######Nginx配置文件nginx.conf中文详解######定义Nginx运行的用户和用户组 user www www;#nginx进程数,建议设置为等于CPU总核心数. worker_pr ...

  6. Announcing the Updated NGINX and NGINX Plus Plug‑In for New Relic (Version 2)

    In March, 2013 we released the first version of the "nginx web server" plug‑in for New Rel ...

  7. Nginx research, nginx module development

    catalog 1. 初探nginx架构 2. handler模块 3. Nginx编译.安装.配置 4. Hello World模块开发 1. 初探nginx架构 nginx在启动后,在unix系统 ...

  8. amazon linux 安装nginx,linux – NGINX不显示Amazon EC2实例上的默认页...

    我在Fedora上安装了nginx.但我不知道为什么我不能通过浏览器请求服务器IP来获取默认的nginx页面.我的请求因超时而下降. 但是nginx正在运行. $sudo service nginx ...

  9. 【Nginx】Nginx配置文件参数/启动参数详解;启动/停止/重新加载配置命令

    nginx配置文件 nginx及其模块的工作方式是由配置文件指定,默认情况下配置文件被命名为nginx.conf并且存放在/usr/local/nginx/conf或者 /etc/nginx或者 /u ...

  10. nginx优化-nginx事件处理模型优化use epoll;

    性能优化-nginx事件处理模型优化use epoll; 在events区块中添加 use epol; 在主配置文件nginx.conf中配置 [root@web01 conf]# cat /appl ...

最新文章

  1. 第二章 如何学习Linux(鸟哥的Linux私房菜基础学习篇)
  2. OpenStack和Redis
  3. win7 64 iis7+access ADODB.Connection 错误 '800a0e7a'
  4. BZOJ2212——线段树合并
  5. dns的主从服务器的简单配置
  6. 深度学习(31)随机梯度下降九: Himmelblau函数优化实战
  7. [Ext JS] 3.3 树(Tree)的定义和使用
  8. [转]一个程序员的哲学思考(关于编程、关于人生)
  9. 天视通ipc地址修改工具_远程运行小工具PsExec
  10. 智能优化算法——蝙蝠算法(PythonMatlab实现)
  11. 土壤因子-中国和世界土壤因子数据说明和下载链接
  12. LaTex编辑器编辑公式
  13. C++改Java——个人银行账户管理
  14. vue的基础知识-vue基础入门
  15. 人体工学电脑椅选购建议 | 潘魏增
  16. 《MLB棒球创造营》:走近棒球运动·亚利桑那响尾蛇队
  17. 利弗莫尔的操盘精华篇
  18. 迎接“119”消防宣传日|助力企事业单位实现消防安全,前景互联在行动
  19. Windows Server 2003 漫游用户配置文件配置详解
  20. 美联邦调查局 FBI 网站被黑,数千特工信息泄露

热门文章

  1. python数据库实现注册函数_10.注册和登录功能实现(3)—— 注册数据写入数据库...
  2. 从零开始学前端:CSS元素模式的转换和CSS三大特性 --- 今天你学习了吗?(CSS:Day12)
  3. cocos中如何让背景模糊_cocos2dx-js Shader的使用(高斯模糊)
  4. 使用Python自由切分pdf文件提取任意页面
  5. Python+matplotlib设置y轴标签距离、位置、竖排
  6. latex图片_Latex使用图片、文献、模板——自定义与路径指定
  7. 416. 分割等和子集(JavaScript)
  8. java 千位分隔,如何在Java中设置千位分隔符?
  9. gitea无法连接mysql_Git push ERROR: Repository not found fatal:无法连接远程数据库
  10. 计算机五大逻辑部件数据流,211计算机基础知识综合篇.ppt