时间:2020-11-12来源:www.pcxitongcheng.com作者:电脑系统城
nginx配置proxy_pass时url末尾带“/”与不带“/”的区别如下:
注意:当location为正则表达式匹配模式时,proxy_pass中的url末尾是不允许有"/"的,因此正则表达式匹配模式不在讨论范围内。
proxy_pass配置中url末尾带/时,nginx转发时,会将原uri去除location匹配表达式后的内容拼接在proxy_pass中url之后。
测试地址:http://192.168.171.129/test/tes.jsp
场景一:
?1 2 3 |
location ^~ /test/ { proxy_pass http: //192 .168.171.129:8080 /server/ ; } |
代理后实际访问地址:http://192.168.171.129:8080/server/tes.jsp
场景二:
?1 2 3 |
location ^~ /test { proxy_pass http: //192 .168.171.129:8080 /server/ ; } |
代理后实际访问地址:http://192.168.171.129:8080/server//tes.jsp
场景三:
?1 2 3 |
location ^~ /test/ { proxy_pass http: //192 .168.171.129:8080/; } |
代理后实际访问地址:http://192.168.171.129:8080/tes.jsp
场景四:
?1 2 3 |
location ^~ /test { proxy_pass http: //192 .168.171.129:8080/; } |
代理后实际访问地址:http://192.168.171.129:8080//tes.jsp
proxy_pass配置中url末尾不带/时,如url中不包含path,则直接将原uri拼接在proxy_pass中url之后;如url中包含path,则将原uri去除location匹配表达式后的内容拼接在proxy_pass中的url之后。
测试地址:http://192.168.171.129/test/tes.jsp
场景一:
?1 2 3 |
location ^~ /test/ { proxy_pass http: //192 .168.171.129:8080 /server ; } |
代理后实际访问地址:http://192.168.171.129:8080/servertes.jsp
场景二:
?1 2 3 |
location ^~ /test { proxy_pass http: //192 .168.171.129:8080 /server ; } |
代理后实际访问地址:http://192.168.171.129:8080/server/tes.jsp
场景三:
?1 2 3 |
location ^~ /test/ { proxy_pass http: //192 .168.171.129:8080; } |
代理后实际访问地址:http://192.168.171.129:8080/test/tes.jsp
场景四:
?1 2 3 |
location ^~ /test { proxy_pass http: //192 .168.171.129:8080; } |
代理后实际访问地址:http://192.168.171.129:8080/test/tes.jsp
到此这篇关于nginx配置proxy_pass中url末尾带/与不带/的区别详解的文章就介绍到这了
2023-03-17
Nginx主机域名配置实现2023-03-17
Nginx配置-日志格式配置方式2023-03-17
Apache APISIX Dashboard 未授权访问漏洞分析(CVE-2021-45232)正常项目无法访问(Linux 服务器),启动tomcat时卡在下图位置,项目无法启动。1、先检查tomcat日志、项目日志没有报错信息,且没再产生新的日志信息。2、jdk、tomcat 、 jvm 配置,服...
2023-03-15
这篇文章主要介绍了Kubernetes中Nginx服务启动失败排查流程(Error: ImagePullBackOff),本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以...
2023-03-15