Loading

21、nginx之ngx_http_proxy_module模块

Nginx 的代理功能是通过 ngx_http_proxy_module 模块来实现的。默认在安装 Nginx 时已经安装了ngx_http_proxy_module模

块,因此可直接使用 ngx_http_proxy_module 模块。

21.1、ngx_http_proxy_module模块介绍:

1、proxy_pass 属于 ngx_http_proxy_module 模块,此模块可以将请求转发到另一台服务器,在实际的反向代理工作中,

会通过 location 功能匹配指定的 URI,然后把接收到的符合匹配 URI 的请求通过 proxy_pass 抛给定义好的upstream节

点池。


2、官网地址:http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass


3、官网 proxy_pass 使用案例:

(1)将匹配 URI 为 name 的请求抛给 http://127.0.0.1/remote/:

location /name/ {

proxy_pass http://127.0.0.1/remote/;

}


(2)将匹配 URI 为 some/path 的请求抛给 http://127.0.0.1:

location /some/path/ {

proxy_pass http://127.0.0.1;

}


(3)将匹配 URI 为 name 的请求应用指定的 rewrite 规则,然后抛给 http://127.0.0.1:

location /name/ {

rewrite /name/([^/]+) /users?name=$1 break;

proxy_pass http://127.0.0.1;

}


21.2、ngx_http_proxy_module模块参数说明:




posted @ 2020-03-14 21:50  云起时。  阅读(1265)  评论(0编辑  收藏  举报