分类目录
-
近期文章
链接表
功能
Tag Archives: nginx
nginx的log
access_log的最小作用域是location,关闭方式是:access_log off; error_log的最小作用域是http,关闭方式是:error_log /dev/null; 如果一个请求是404之类的,则access_log中记录404,error_log同时会记录open filename failed等错误,如果不需要,可以改变http域error_log的记录等级,也可以直接关闭(还有log_not_found选项可以关闭记录open filename failed错误)。
nginx的rewrite
设置nginx的rewrite如果替换项是以http://开头,则起的是redirect的作用,即使最后的参数是last不是redirect,例如: rewrite ^(.*)$ http://aaa.bbb.com/ccc$1 last; 浏览器端会得到302。 nginx的文档里提到: redirect – returns temporary redirect with code 302; it is used if the substituting line begins with http:// 另外,rewrite后的host的使用顺序如下: 当请求的http头里的host匹配sever_name里的任一host时,使用此host 若不匹配,或者为空,使用server_name的第一个host 若没有设置server_name,则使用本机的hostname 若要一直使用http头里的host,则将server_name设置为:servername _ *;(下划线不能少,因为 * 不能做为sever_name第一项的开头)