Strip Character from Server Variable

Hi all,

I am trying to do something that sounds very simple and yet has me
perplexed. I need to strip the leading / from the $uri variable in my
nginx.conf. I need to then pass that modified variable to ProxyPass.

I can’t for the life of me figure out how to this in the nginx.conf
syntax.

Thanks in advance.

James

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,223166,223166#msg-223166

On Wednesday 29 February 2012 18:38:14 jamessinton wrote:

map $uri $uri_stripped {
default $uri;
~^/(?P.*)$ $s;
}

http://wiki.nginx.org/HttpMapModule

or

if ($uri ~ "^/(.*)$") {
    set $uri_stripped $1;
}

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#if
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#set

wbr, Valentin V. Bartenev

On Wednesday 29 February 2012 18:52:40 Valentin V. Bartenev wrote:

Thanks in advance.
if ($uri ~ “^/(.*)$”) {
set $uri_stripped $1;
}

http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#if
http://nginx.org/en/docs/http/ngx_http_rewrite_module.html#set

or, maybe you just want this:

 location ~ ^/(.*)$ {
     ...
     fastcgi_param SOME $1; # just for example
 }

wbr, Valentin V. Bartenev

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs