Nginx配置proxy_pass转发的路径问题.docxVIP

  • 7
  • 0
  • 约 2页
  • 2021-11-08 发布于江苏
  • 举报
Nginx配置proxy_pass转发的路径问题.docx

Nginx 配置proxy_pass 转发的/路径问题 在 nginx 中配置 proxy_pass 时,如果是按照^~ 匹配路径时,要注意 proxy_pass 后的 url 最后的/,当加上了/,相当于是绝对根路径,则 nginx 不会把location中匹配的路径部分代理走; 如果没有/,则会把匹配的路径部分也给代理走。 location^~/static_js/ { proxy_cachejs_cache; proxy_set_headerH; proxy_pass ;/ } 如上面的配置,如果请求的 url是 http://servername/static_js/test.html 会被代理成 /test.html 而如果这么配置 location^~/static_js/ { proxy_cachejs_cache; proxy_set_headerH; proxy_pass http://js.test.co;m } 则会被代理到 /static_js/test.htm 当然,我们可以用如下的 rewrite来实现/的功能 location^~/static_js/ { proxy_cachejs_cache; proxy_set_headerH; rewrite/static_js/(.+)$/$1break; proxy_pass http://js.tes

文档评论(0)

1亿VIP精品文档

相关文档