本文介绍Nginx服务器配置proxy_pass转发的/路径,希望对于初学Nginx服务器相关的朋友有帮助,更多Nginx安装、配置、报错处理等资源请本站内搜索。。
location ^~ /static_js/
{
proxy_cache js_cache;
proxy_set_header Host www.server110.com;
proxy_pass http://www.server110.com/;
}
如上面的配置,如果请求的url是http://servername/static_js/88181.html
会被代理成http://www.server110.com/88181.html
而如果这么配置
location ^~ /static_js/
{
proxy_cache js_cache;
proxy_set_header Host www.server110.com;
proxy_pass http://www.server110.com;
}
则会被代理到http://www.server110.com/static_js/88181.htm
当然,我们可以用如下的rewrite来实现/的功能
location ^~ /static_js/
{
proxy_cache js_cache;
proxy_set_header Host www.server110.com;
rewrite /static_js/(.+)$ /$1 break;
proxy_pass http://www.server110.com;
}
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。