0

Here is my situation.

I wrote a nginx module. one step is to send a subrequest to download a file from an external site like this.

ngx_http_subrequest(r, &(ctx->uri), &(ctx->uri_parameter), &sr, NULL, 0);

the uri above looks like this /aliyun_download/testbalabalabala.pdf the url_parameter looks like this. The parameter is url encoded

OSSAccessKeyId=dCPhhptMqGgftrD5&Signature=Hiu%2F67oTrNATZXhvwmH1dphEyjE%3D&Expires=1402323454

The nginx config I wrote looks like this

 location /aliyun_download/ {
            proxy_pass http://dev-data-primary.aliyuncs.com/;
 }

But the problem I have is that the url which I use to download the file is url encoded, but it seems that nginx automatically decoded the url during proxy and send the un-encoded url to the external server. Since the external server is expecting the encoded url, it returns errors.

Can some nginx expert help me figure out how exactly I can solve this problem or correctly configure the nginx.

Thanks a lot!

Yuan Cheng
  • 41
  • 3
  • Maybe [this](http://serverfault.com/a/463932/164840) answer would be of help. As a fast first troubleshooting, try removing the trailing slash: `proxy_pass http://dev-data-primary.aliyuncs.com;` – Marcel Jun 09 '14 at 16:33
  • I saw this post earlier and tried, the solution seems not work for me – Yuan Cheng Jun 10 '14 at 05:42
  • @YuanCheng, perhaps http://stackoverflow.com/a/37584637/1122270 would be of some help? – cnst Jun 02 '16 at 07:00
  • Possible duplicate of [Nginx pass\_proxy subdirectory without url decoding](https://stackoverflow.com/questions/28684300/nginx-pass-proxy-subdirectory-without-url-decoding) – cnst Dec 17 '18 at 19:20

0 Answers0