常用关键词:rewrite、proxy_pass
location ^~ /address/ {
proxy_set_header Host xx.sohu.com; #设置header
proxy_set_header Origin http://xx.sohu.com;
#proxy_set_header Cookie "$http_cookie; coder=lxf"; #一般cookie会自动转发,此处可以追加cookie
#proxy_pass http://192.168.1.1:8888/; # hostNow/address/a 转发至 hostOther/a,等效于下面两行
rewrite /address/(.+)$ /$1 break; #正则匹配
proxy_pass http://192.168.1.1:8888;
}
location ~ (getList|search|folders) { #正则匹配
proxy_set_header Host free-mail-backend-test.sce.sohuno.com;
proxy_set_header Origin http://free-mail-backend-test.sce.sohuno.com;
proxy_pass http://free-mail-backend-test.sce.sohuno.com;
}
参考:
http://www.cnblogs.com/AloneSword/p/3673829.html
http://linux.it.net.cn/e/server/nginx/2014/0709/2704.html
原文:http://www.cnblogs.com/youryida/p/5422067.html