【标题】:Nginx location “/” 配置
服务访问
服务请求如下(示例):
- nginx服务: http://127.0.0.1:80
- 后台服务:http://127.0.0.1:8088
- 测试url地址:http://127.0.0.1:8088/test/api/findAll
场景一、
nginx配置:
location /test/ {
proxy_pass http://127.0.0.1:8088/;
}
请求地址:http://127.0.0.1/test/api/findAll
实际上服务请求地址为:http://127.0.0.1:8088/api/findAll
规则:location最后有"/“,proxy_pass最后有”/" 结果为 proxy_pass + url中location最后一个斜线以后的部分
以下是实例:
以下实例为
springboot
中有个test
请求的方法,然后返回值为String类型,通过thymeleaf渲染到test页面而以上nginx配