[英]Nginx redirecting to an encoded URL passed as a argument in nginx?
I want to redirect from nginx to a URL that is send as an argument in the encoded form.我想从 nginx 重定向到以编码形式作为参数发送的 URL。
location /v1/redirect {
access_log /var/log/nginx/redirect/access.log main;
error_log /var/log/nginx/redirect/error.log;
return 302 $arg_dest;
}
When I am passing unencoded URL for eg https://ex2.example2.com/v1/redirect?dest=https://ex1.example2.com
It is working fine.当我传递未编码的 URL 例如
https://ex2.example2.com/v1/redirect?dest=https://ex1.example2.com
,它工作正常。
But on encoding dest argument as https://ex2.example2.com/v1/redirect?dest=https%3A%2F%2Fex1.example2.com
.但是将 dest 参数编码为
https://ex2.example2.com/v1/redirect?dest=https%3A%2F%2Fex1.example2.com
。 I am getting status code 304 and my URL is changing to https://ex2.example2.com/v1/https%3A%2F%2Fex1.example2.com
.我收到状态代码 304,我的 URL 正在更改为
https://ex2.example2.com/v1/https%3A%2F%2Fex1.example2.com
Can someone help me identify what I am doing wrong, Is there a way to possibly URL decode arg_dest before passing to return?有人可以帮我确定我做错了什么吗,有没有办法让 URL 在传递返回之前解码 arg_dest? Thanks
谢谢
njs can be used to solve the above problem.可以使用njs来解决上述问题。 Take a look at https://github.com/xeioex/njs-examples/blob/master/conf/http/decode_uri.conf and https://github.com/xeioex/njs-examples/blob/master/njs/http/decode_uri.js to solve the above problem.
看看https://github.com/xeioex/njs-examples/blob/master/conf/http/decode_uri.conf和https://github.com/xeioex/njs-examples/blob/master/njs/ http/decode_uri.js来解决上述问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.