我需要代理请求从我的服务器到另一个服务器应该实现两个选项
:
从https://my-site.com/subjects/custom_id到https://another-site.com/subjects/custom_id
的例子:
https://my-site.com/subjects/1 to https://another-site.com/subjects/1
https://my-site.com/subjects/2 to https://another-site.com/subjects/2
Nginx config (works fine):location ~ ^/subjects/?(.*) {
resolver 8.8.8.8;
proxy_pass https://another-site.com/subjects/$1$is_args$args;
}
第二:
从https://my-site.com/subjects?code=custom_code到https://another-site.com/subjects?code=custom_code
的例子:
https://my-site.com/subjects?code=1 to https://another-site.com/subjects?code=1
https://my-site.com/subjects?code=2 to https://another-site.com/subjects?code=2
如何编写Nginx配置?
修正:
location ^~ /subjects {
resolver 8.8.8.8;
proxy_pass https://another-site.com/subjects;
}