nginx配置api转发时结尾带不带斜杠的区别是什么
nginx配置api转发时结尾带不带斜杠区别前端:dist 放在 nginx/html/dist后端接口:/api/** 转发到 springbootserver { listen 80;
nginx配置api转发时结尾带不带斜杠区别
- 前端:
dist 放在 nginx/html/dist - 后端接口:
/api/** 转发到 springboot
server {
listen 80;
server_name localhost;
# 前端静态资源
location / {
root html/dist;
index index.html index.htm;
try_files $uri $uri/ /index.html; # vue/react 路由刷新
}
# 后端接口代理
location /api/ {
proxy_pass http://127.0.0.1:8080/api/;
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
}
}
结尾不带/的
location /api/{
proxy_pass http://127.0.0.1:8080
}
| 请求地址 | 转发到后端地址 |
|---|
| /api/user/login | http://127.0.0.1:8080/api/user/login |
| /api/getinfo | http://127.0.0.1:8080/api/getinfo |
| /api/order/list | http://127.0.0.1:8080/api/order/list |
结尾带/的
location /api/{
proxy_pass http://127.0.0.1:8080/
}
| 请求地址 | 转发到后端地址 |
|---|
| /api/user/login | http://127.0.0.1:8080/user/login |
| /api/getinfo | http://127.0.0.1:8080/getinfo |
| /api/order/list | http://127.0.0.1:8080/order/list |
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
相关文章:
-
简单的java输入输出一.输出java的输出有下面三种方式,一一来介绍1·system.out.println()要输出的内容放在后面的括号内,输出变量的值直接写变量…
-
-
-
-
-
版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。
发表评论