【发布时间】:2021-04-26 10:35:42
【问题描述】:
我需要对通过查询参数传递的 url 进行代理调用,例如:
我的 nginx 代理部署在:https://myproxy.net
如果重定向参数不是 url 编码的,我可以使用这个块进行调用:
location /basepath {
if ( $arg_redirect = '') {
return 400 "Missing redirect directive in request";
}
proxy_pass $arg_redirect;
proxy_intercept_errors on;
error_page 301 302 307 = @handle_redirects;
}
错误拦截和@handle_redirects 然后处理可能在新目的地弹出的其他 30X 代码。
这适用于请求:GET: https://myproxy.net/basepath?redirect=https://destination.com/somepath/uuid
我需要做什么才能使其工作:GET:https://myproxy.net/basepath?redirect=https%3A%2F%2Fdestination.com%2Fsomepath%2Fuuid
此外,作为规范的一部分,它必须是纯 nginx,而不是附加模块、lua 等。 谢谢!
【问题讨论】:
标签: nginx nginx-reverse-proxy nginx-location