1、转发路径以端口结尾不添加根路径的情况
请求:http://127.0.0.1/appStore/api/getTest
以下全部基于此请求进行映射说明,红色为推荐配置
配置1:
只替换到端口的那一部分
location ^~ /appStore {
proxy_pass http://127.0.0.1:9222;
}
实际:http://127.0.0.1:9222/appStore/api/getTest
配置2:
location ^~ /appStore/ {
proxy_pass http://127.0.0.1:9222;
}
实际:http://127.0.0.1:9222/appStore/api/getTest
配置3:
替换到标识的路径部分
location ^~ /appStore {
proxy_pass http://127.0.0.1:9222/;
}
实际:http://127.0.0.1:9222//api/getTest
配置4:
location ^~ /appStore/ {
proxy_pass http://127.0.0.1:9222/;
}
实际:http://127.0.0.1:9222/api/getTest
2、转发路径以端口结尾添加根路径的情况
请求:http://127.0.0.1/appStore/api/getTest
配置1:
替换到标识的路径部分
location ^~ /appStore {
proxy_pass http://127.0.0.1:9222/appStore;
}
实际:http://127.0.0.1:9222/appStore/api/getTest
配置2:
location ^~ /appStore/ {
proxy_pass http://127.0.0.1:9222/appStore;
}
实际:http://127.0.0.1:9222/appStoreapi/getTest
配置3:
location ^~ /appStore {
proxy_pass http://127.0.0.1:9222/appStore/;
}
实际:http://127.0.0.1:9222/appStore//api/getTest
配置4:
location ^~ /appStore/ {
proxy_pass http://127.0.0.1:9222/appStore/;
}
实际:http://127.0.0.1:9222/appStore/api/getTest