Nginx转发配置易错点
假设网站域名为 domain
。
案例
如下配置
# 代理 API 请求到后端服务
location /openapi/ {
# 注意 proxypass
proxy_pass http://backend/;
}
访问 domain/openapi/callback
SpringMVC 后端能响应的接口是
@GetMapping("/callback")
如下配置
# 代理 API 请求到后端服务
location /openapi/ {
# 注意 proxypass
proxy_pass http://backend;
}
访问 domain/openapi/callback
SpringMVC 后端能响应的接口是
@GetMapping("/openapi/callback")
总结
当 location
为 /xx/
同时 proxypass
最后带 /
,最终转发时 xx
会被替换为空。
评论
其他文章