Nginx中proxy_pass指令的使用
今天在配置
nginx.conf
时发现proxy_pass
指令有几点需要注意的地方。以下为nginx的配置文件:
1 | #分布式图片服务器:可进行负载均衡 |
在nginx中配置
proxy_pass
代理转发时,如果在proxy_pass
后面的url加/
,表示绝对根路径;- 如
xuecheng.com/cms/preview/test.html
的转发地址为http://cms_server_pool/cms/preview/test.html
- 如
如果在
proxy_pass
后面没有/
,表示相对路径。location
指令后匹配的路径部分也会添加到代理地址中。- 如
img.xuecheng.com/group1/xxxx.png
的转发地址为http://img_server_pool/group1/xxxx.png
(经过负载均衡发送请求给不同的服务器)
- 如
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 HumgTop's Blog!
评论