nginx反向代理增加虚拟目录

为nginx反向代理增加虚拟目录


比如:


将http://domain.com/test/abc.html 代理到 http://127.0.0.1/abc.html


方法一:


在反向代理路径后面添加"/"


location /test {
    proxy_pass http://127.0.0.1/;
}


方法二:


使用rewrite


location /test {
    rewrite /test/(.*) /$1 break;
    proxy_pass http://127.0.0.1;
}


猜你喜欢

转载自blog.51cto.com/4988084/2121621