Nginx 学习笔记
来源:互联网 发布:linux xen 编辑:程序博客网 时间:2024/04/29 07:45
1 Nginx配置proxy_pass转发的/路径问题
http://www.cnblogs.com/AloneSword/p/3673829.html
Nginx配置proxy_pass转发的/路径问题
在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; }
则会被代理到http://js.test.com/static_js/test.htm
当然,我们可以用如下的rewrite来实现/的功能
location ^~ /static_js/ { proxy_cache js_cache; proxy_set_header Host js.test.com; rewrite /static_js/(.+)$ /$1 break; proxy_pass http://js.test.com; }
0 0
- nginx学习笔记
- Nginx学习笔记
- Nginx学习笔记
- nginx学习笔记0
- nginx学习笔记1
- nginx学习笔记2
- nginx学习笔记
- nginx学习笔记
- nginx rewrite学习笔记
- nginx学习笔记【安装】
- nginx学习笔记1
- nginx学习笔记2
- Nginx学习笔记 第一章
- nginx学习笔记
- nginx 新手学习笔记
- Nginx学习笔记1
- nginx的学习笔记
- nginx 源代码学习笔记
- Java获取一年有多少周、某周的第一天和最后一天.
- Myeclipse新建JSP文件默认生成代码详解
- 抽象工厂模式(三)
- ConcurrentModificationException
- android 自定义view 实例CityPickerView
- Nginx 学习笔记
- ASP.NET-GridView之表头设计
- 图像处理中常用数学知识
- qt 打印 刻度尺 曲线 复杂图像
- Android View系统源码分析(十三)—— View.requestFocus() & ViewRoot.requestLayout()
- 解决ADT Eclipse项目的Preference中,Java Compiler下没有Annotation Processing
- 我最喜欢的9个 Python深度学习库
- hdu3863 No Gamblin 博弈
- Android最便捷的屏幕适配,堪称屏幕适配终结者