首页 > 其他 > 详细

rewrite-proxy_pass

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

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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!