关于nginx反向代理中指令proxy_pass的使用
位置:location
作用:作为中转站,将请求转发给后台服务器(代理后台服务器)
这里使用两个nginx,一个作为代理服务,一个作为后台服务。
proxy_pass指定的地址不以 / 结尾;
访问:http://192.168.242.200/proxy/1.txt
uri:/proxy/1.txt
location:/proxy
代理地址:http://192.168.242.201
转发请求为:http://192.168.242.201/proxy/1.txt= 代理地址 + uri
proxy_pass指定的地址以 / 结尾
访问:http://192.168.242.200/proxy/1.txt
uri:/proxy/1.txt
location:/proxy( /proxy 和 /proxy/ 结果一致)
代理地址:http://192.168.242.201/
转发请求为:http://192.168.242.201/1.txt= 代理地址 + (uri - location)