Nginx proxy pass简单用法
2013-04-27 14:36
471 查看
一,在nginx中配置proxy_pass时的加不加/的问题 要注意proxy_pass后的url最后的/ 当加上了/,相当于是绝对根路径,则nginx不会把location中匹配的路径部分代理走 如果没有/,则会把匹配的路径部分也给代理走 例: location ^~ /static_js/ { proxy_cache js_cache; proxy_set_header Host js.test.com; proxy_pass http://js.test.com/; } 如上面的配置,如果请求的url是http://servername/static_js/test.html 会被代理成http://js.test.com/test.html 而如果这么配置 例: location ^~ /static_js/ { proxy_cache js_cache; proxy_set_header Host js.test.com; proxy_pass http://js.test.com; } 如上面的配置,如果请求的url是http://servername/static_js/test.html 则会被代理到http://js.test.com/static_js/test.htm 二,关于proxy_pass配置的uri问题 你不想nginx对你的URI请求有任何形式的修改,那么,proxy_pass的配置中就不应该有任何URI部分。 举个例子,nginx服务器IP为10.0.0.20,它的配置不含URI: location /firstcond/ { proxy_pass http://10.0.0.30:90; } 那么, 原:http://10.0.0.20/first/second/test.html 转:http://10.0.0.30:90/first/second/test.html 如果配置成含URI: location /firstcond/ { proxy_pass http://10.0.0.30:90/myuri; } 那么, 原: http://10.0.0.20/first/second/test.html 转:http://10.0.0.30:90/myuri/test.html 简单地说,配置了URI之后,跳转行为可能会令你感到莫名其妙。
相关文章推荐
- Nginx proxy pass路由转发简单用法
- Nginx proxy pass路由转发简单用法
- Nginx阅读笔记(三)之proxy_pass用法
- nginx 代理 proxy_pass设置
- Nginx配置proxy_pass转发的/路径问题
- 关于Nginx location中配置proxy_pass转发时斜线'/'导致的404问题
- Nginx配置proxy_pass转发的/路径问题
- nginx,rewrite,proxy_pass,post数据,表单
- 解决nginx使用proxy_pass反向代理时,cookie丢失的问题
- Nginx (proxy_pass)代理配置
- nginx自动跳转网页(proxy_pass)
- nginx做反向代理proxy_pass,proxy_redirect的使用
- [nginx]proxy_pass&rewrite知识点
- nginx中proxy_pass到tomcat的session丢失
- Nginx配置proxy_pass时的注意事项
- nginx "proxy_pass" cannot have URI part in location given by regular expression
- Nginx配置proxy_pass转发的/路径问题
- Nginx配置proxy_pass
- nginx反向代理proxy_pass不配置URI引起的思考
- Nginx配置proxy_pass