10月 192016
 
  1. 重定向
    1. rewrite可以重定向
    2. return 301 $url; 也能重定向,简单的重定向使用return 301更简介,如,强制访问443端口,80段定义如下:

       
  2. return 301 $url ; 不同于 return $url ;
    1. 后者不会导致页面跳转,而是服务器端代为请求了
  3. location = / 不能嵌套在其他的location中,虽然逻辑上似乎合理,但是执行不到
  4. nginx中常用的变量: http://nginx.org/en/docs/varindex.html
  5. lua openresty https://github.com/openresty/lua-nginx-module

关于location:

  1. location之间是互斥的,可以嵌套,但不可以继承,如:
    1. location / 嵌套在 location / 中,虽然没有语法错误,但是,内层的location不会被执行到
    2. location /sub 嵌套在 location / 中时,如果匹配到了location sub 则location / 里面 ,location /sub 外面的逻辑不会被执行到,这就是我所谓的不可以继承,效果等同于并列的两个location
 Posted by at 下午 1:58

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

(required)

(required)

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据