Nginx 处理请求的顺序问题

对于Name-Based virtual servers, nginx 只会测试request 中的header field “Host” 来决定把这个请求route 给谁. 如果这个请求不存在Host这个field, 或者Host 的值不能match 任何一个server_name, 那么nginx就会把这个请求route 给这个port 的default server. 如果我们没有在conf中指明哪个server block 为default_server, 那么nginx 就会把第一个server block认为是default server.

name-based virtual server 的例子如下:

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;
 ...
}

default_server 的例子如下:

server {
 listen 80 default_server;
 server_name example.net www.example.net;
 ...
}

 

对于mixed name-based and ip-based virtual server, 例如:

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;
 ...
}

nginx 的处理顺序是先ip和port 的组合,然后才是server_name.

举个例子就是,如果在192.168.1.1:80上收到了一个www.example.com 的请求的话,那么这个请求就会被发到192.168.1.1:80 的default server, 因为对于这个ip和port 的组合,里面没有这个server_name.

 

MySql 的 ONLY_FULL_GROUP_BY

最近把mysql 升级到了5.7.18 然后就发现了一个很明显的变化, ONLY_FULL_GROUP_BY 这个mysql mode 被加了进来, 按照sql 99 的标准这是好事.

但是实际上, mysql 的这个版本只能说almost identical or very close to, 不能说完全相等

简单的说,就是

That is, MySQL 5.7.5m15 will by default reject only those GROUP 
BY-queries that include non-aggregated expressions in the SELECT-list that 
are not functionally dependent upon the GROUP BY-list.

This not only means that you cannot mess up your GROUP BY-queries anymore 
(as MySQL will now reject an improper GROUP BY query), 
it will also not require you to write non-sensical "dummy" aggregates
 over expressions that can only have one value per aggregated 
result row. Hurrah!

详细的解释请看这篇文章:

http://rpbouman.blogspot.nl/2014/09/mysql-575-group-by-respects-functional.html