網站首頁 編程語言 正文
服務請求如下(示例):
- 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最后一個斜線以后的部分
場景二、
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最后一個斜線以后的部分
場景三、
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/test/api/findAll
規則:location最后有"/“,proxy_pass最后無”/" 結果為 proxy_pass + location + url中location后面的部分(不包含第一個/)
場景四、
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/test/api/findAll
規則:location最后無"/“,proxy_pass最后無”/" 結果為 proxy_pass + location + “/” + url中location后面的部分(不包含第一個/)
以下配置的規則可以參考上面的場景。
場景五、
nginx配置:
location /test/ {
proxy_pass http://127.0.0.1:8088/server/;
}
請求地址:http://127.0.0.1/test/api/findAll
實際上服務請求地址為:http://127.0.0.1:8088/server/api/findAll
場景六、
nginx配置:
location /test {
proxy_pass http://127.0.0.1:8088/server/;
}
請求地址:http://127.0.0.1/test/api/findAll
實際上服務請求地址為:http://127.0.0.1:8088/server//api/findAll
場景七、
nginx配置:
location /test {
proxy_pass http://127.0.0.1:8088/server/;
}
請求地址:http://127.0.0.1/test/api/findAll
實際上服務請求地址為:http://127.0.0.1:8088/serverapi/findAll
場景八、
nginx配置:
location /test {
proxy_pass http://127.0.0.1:8088/server;
}
請求地址:http://127.0.0.1/test/api/findAll
實際上服務請求地址為:http://127.0.0.1:8088/server/api/findAll
總結
以上就是nginx配置文件里location中“/”相關配置的筆記。
原文鏈接:https://blog.csdn.net/SmallCat0912/article/details/125391486
相關推薦
- 2023-05-29 scipy稀疏數組coo_array的實現_python
- 2022-07-07 redis遠程連接不上的解決辦法_Redis
- 2022-07-18 linux系統安全和應用
- 2023-06-04 pandas.DataFrame?Series排序的使用(sort_values,sort_inde
- 2022-06-10 C語言?模擬實現memcpy與memmove函數詳解_C 語言
- 2022-06-17 Ruby序列化和持久化存儲(Marshal、Pstore)操作方法詳解_Golang
- 2022-05-09 Python實現連接FTP并下載文件夾_python
- 2022-10-30 一文詳解如何創建自己的Python裝飾器_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支