id,summary,reporter,owner,description,type,status,priority,milestone,component,version,resolution,keywords,cc,uname,nginx_version 727,Nginx pass_proxy subdirectory without url decoding,Rinat Silnov,,"Hello guys, First of all thank you for this amazing server! Here's an issue I'm trying to solve: I need to write an nginx location directive to proxy requests for subdirectory to another server preserving urlencoding and removing subdirectory prefix. Here's an artificial example — request like this: !http://1.2.3.4/api/save/http%3A%2F%2Fexample.com should pass as !http://abcd.com/save/http%3A%2F%2Fexample.com I tried several different ways. Here're couple of them: {{{ location /api/ { rewrite ^/api(/.*) $1 break; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://abcd.com; } }}} But it decodes the string, so !http://abcd.com gets /save/!http://example.com {{{ location /api/ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_pass http://abcd.com; } }}} But it keeps subdirectory, so !http://abcd.com gets /api/save/http%3A%2F%2Fexample.com. Here's the [http://stackoverflow.com/q/28684300/1224211 question on SO] Is it correct to keep special characters such as {{{"";"" | ""/"" | ""?"" | "":"" | ""@"" | ""&"" | ""="" | ""+"" | ""$"" | "",""}}} decoded after processing? Is there some workaround for this issue? I would prefer to use subdirectory instead of subdomain since this way you don't have to worry about CORS etc Thanks a lot!",defect,closed,major,,nginx-core,1.2.x,invalid,proxy_pass,,Linux ip-10-73-181-14 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux,"nginx version: nginx/1.2.1 TLS SNI support enabled configure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-pcre-jit --with-debug --with-http_addition_module --with-http_dav_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/tmp/buildd/nginx-1.2.1/debian/modules/nginx-auth-pam --add-module=/tmp/buildd/nginx-1.2.1/debian/modules/nginx-echo --add-module=/tmp/buildd/nginx-1.2.1/debian/modules/nginx-upstream-fair --add-module=/tmp/buildd/nginx-1.2.1/debian/modules/nginx-dav-ext-module"