This topic created in 2280 days ago, the information mentioned may be changed or developed.
一个请求 /api1/auth/loginout/
我在接收到 /api1/auth/loginout 的请求后要把请求首地址 api1 转发到另一个服务器的 auth/logunout/接口要如何去写
这么写的话转发过去 请求接口依然是 /api1/auth/loginout
location /api1 {
proxy_pass http://192.168.0.1:5000/;
}
5 replies 2020-03-06 03:45:52 +08:00  | | 1 leahoop Mar 5, 2020 1 location /api1/auth/loginout { proxy_pass http://ip/auth/loginout; } |
 | | 2 wsb200514 Mar 5, 2020 2 增加一个'/': location /api1/ { proxy_pass http://192.168.0.1:5000/; } 或者: location /api1/auth/ { proxy_pass http://192.168.0.1:5000/auth/; } 等等。 写法有很多,最好查一下相关文档,全面理解一下。 |
 | | 4 GM Mar 5, 2020 1 location /api1/ { <-------------注意结尾这个斜杠,必须要有 proxy_pass http://192.168.0.1:5000/; } |
 | | 5 Shoukaku Mar 6, 2020 1 是只有 /api1/auth/loginout/这个请求吗,还是 /api1 下的所有请求? 可以看一下 nginx 的 rewrite 模块,我觉得是跟你需求比较接近的一种简单的实现方式 |