码迷,mamicode.com
首页 > 其他好文 > 详细

rewrite-proxy_pass

时间:2017-02-27 22:05:56      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:permanent   tuangou   images   图片   server   

Nginx的rewrite

    rewrite regex replacement flag;

    rewrite ^/images/(.*\.jpg)$ /imgs/$1 所有的图片跳转到/imgs/$1

     break;(结束位)

     rewrite ^/shop/(.*\html)$ /tuangou/$1 break;

    rewrite ^/shop/(.*\.php)$ http://www.baidu.com/$1 [redirect | permanent]; 

    last - 基本上都用这个Flag(多级跳转)

    break - 中止Rewirte,不在继续匹配

    redirect - 返回临时重定向的HTTP状态302

    permanent - 返回永久重定向的HTTP状态

    ^(.*)$ //所有的请求

    301

rewrite的confition

    语法:if  (condition) {..}

    应用环境:server,location

    
upsteam name{ //nginx负载均衡

    wrr; //加权算法

    server //外部服务器 weight=2 max_fails=1 fail_timeout=1s;

    server //外部服务器 weight=1 [down | backup];


}//单配置到http段

lcation / {

    proxy_pass http://name; //跳转到http://name 

}

error_page 404 /404.html;

location = /404.html {

    root /web/404;

}

alias /web  把"/" 别名成/web   


rewrite-proxy_pass

标签:permanent   tuangou   images   图片   server   

原文地址:http://knowledgeq.blog.51cto.com/9549168/1901667

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!