I want to redirect from nginx to a URL that is send as an argument in the encoded form.
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 e.g. https://ex2.example2.com/v1/redirect?dest=https://ex1.example2.com
It is working fine.
But on encoding dest argument as 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
.
Can someone help me identify what I am doing wrong, Is there a way to possibly URL decode arg_dest before passing to return? Thanks