问ChatGPT和上网搜索都是告诉我只要在Nginx config里,路径代码之后加个return就行,也就是这样
location /my-path {
# handle requests to /my-path locally
proxy_pass http://localhost:8080;
}
# redirect all other requests to another server
return 302 https://other-server.com$request_uri;
但是我实际上试了下不行,访问my-path也还是会跳转到别的域名,实际上应该这么解决
location /my-path {
# handle requests to /my-path locally
proxy_pass http://localhost:8080;
}
location / {
return 302 https://other-server.com$request_uri;
}
得把return也放在自己的location里面
文章评论