nginx sub_filter重定向
时间: 2023-08-21 10:06:17 浏览: 218
nginx sub_filter指令用于在代理服务器上替换响应内容中的某个字符串。在给定的配置样例中,sub_filter指令被用来重定向URL。在第一个配置样例中,sub_filter指令将响应中的'http://www.nginxbar.com/'替换为'http://www.nginxbar.org/books'。这样,当客户端访问'/books'时,代理服务器会将请求转发到'http://www.nginxbar.com',并将响应中的重定向URL替换为'http://www.nginxbar.org/books'。在第二个配置样例中,sub_filter指令用于替换'/login'为'/j/login','/static/'为'/j/static/',以及'/adjuncts'为'/j/adjuncts'。这样,当客户端访问'/j/'时,代理服务器会将请求转发到'http://127.0.0.1:8002',并将响应中对应的字符串进行替换。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [当Nginx遇到重定向](https://blog.csdn.net/hzbooks/article/details/109324553)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [nginx add_header指令使用方法](https://download.csdn.net/download/weixin_38735541/12903169)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [nginx中的sub_filter](https://blog.csdn.net/scugxl/article/details/105460177)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文