nginx removes double slashes

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

nginx removes double slashes

Gregory Edigarov
Hello everybody,

perhaps I am doing something wrong:

         location /njs/ {
                 rewrite /njs/(.*)$ /$1 break;
                 proxy_redirect off;
                 proxy_set_header Host $http_host;
                 proxy_set_header X-Real-IP $remote_addr;
                 proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
                 proxy_set_header X-Forwarded-Proto $scheme;
                 proxy_pass <a href="http://localhost:4006;">http://localhost:4006;

         }
calling this
http://[hostname]/facebook/bitly/http%3A%2F%2F[hostname]%2Fbeth-buczynski%2Fdiy-ways-to-stay-warm-in-winter%2F

and I definitely see that to my application it comes like:
http:/[hostname]/beth-buczynski/diy-ways-to-stay-warm-in-winter/
note the single '/', when I need '//'

Is there any way to handle it?
--
With best regards,
       Gregory Edigarov

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx removes double slashes

Gregory Edigarov

On 12/29/2014 01:04 PM, Gregory Edigarov wrote:

> Hello everybody,
>
> perhaps I am doing something wrong:
>
>         location /njs/ {
>                 rewrite /njs/(.*)$ /$1 break;
>                 proxy_redirect off;
>                 proxy_set_header Host $http_host;
>                 proxy_set_header X-Real-IP $remote_addr;
>                 proxy_set_header X-Forwarded-For
> $proxy_add_x_forwarded_for;
>                 proxy_set_header X-Forwarded-Proto $scheme;
>                 proxy_pass <a href="http://localhost:4006;">http://localhost:4006;
>
>         }
> calling this
> http://[hostname]/facebook/bitly/http%3A%2F%2F[hostname]%2Fbeth-buczynski%2Fdiy-ways-to-stay-warm-in-winter%2F
>
>
> and I definitely see that to my application it comes like:
> http:/[hostname]/beth-buczynski/diy-ways-to-stay-warm-in-winter/
> note the single '/', when I need '//'
>
> Is there any way to handle it?
Also, if  I call my application directly, not via nginx - that works
correctly.

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx removes double slashes

B.R.
The proxy_pass documentation is a bit unclear to me, but I it is a fact that double slashes are replaced by single ones as the result of the normalization of the URI.

However, I do not get the following parts:
"If proxy_pass is specified without a URI, the request URI is passed to the server in the same form as sent by a client when the original request is processed, or the full normalized request URI is passed when processing the changed URI: "

and

"Before version 1.1.12, if proxy_pass is specified without a URI, the original request URI might be passed instead of the changed URI in some cases."

Calling out to nginx pros: When is the original request processed? When is it not?
---
B. R.

On Mon, Dec 29, 2014 at 1:14 PM, Gregory Edigarov <[hidden email]> wrote:

On 12/29/2014 01:04 PM, Gregory Edigarov wrote:
Hello everybody,

perhaps I am doing something wrong:

        location /njs/ {
                rewrite /njs/(.*)$ /$1 break;
                proxy_redirect off;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_pass http://localhost:4006;

        }
calling this
http://[hostname]/facebook/bitly/http%3A%2F%2F[hostname]%2Fbeth-buczynski%2Fdiy-ways-to-stay-warm-in-winter%2F

and I definitely see that to my application it comes like:
http:/[hostname]/beth-buczynski/diy-ways-to-stay-warm-in-winter/
note the single '/', when I need '//'

Is there any way to handle it?
Also, if  I call my application directly, not via nginx - that works correctly.


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx


_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx removes double slashes

Maxim Dounin
In reply to this post by Gregory Edigarov
Hello!

On Mon, Dec 29, 2014 at 01:04:06PM +0200, Gregory Edigarov wrote:

> Hello everybody,
>
> perhaps I am doing something wrong:
>
>         location /njs/ {
>                 rewrite /njs/(.*)$ /$1 break;
>                 proxy_redirect off;
>                 proxy_set_header Host $http_host;
>                 proxy_set_header X-Real-IP $remote_addr;
>                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>                 proxy_set_header X-Forwarded-Proto $scheme;
>                 proxy_pass <a href="http://localhost:4006;">http://localhost:4006;
>
>         }
> calling this
> http://[hostname]/facebook/bitly/http%3A%2F%2F[hostname]%2Fbeth-buczynski%2Fdiy-ways-to-stay-warm-in-winter%2F
>
> and I definitely see that to my application it comes like:
> http:/[hostname]/beth-buczynski/diy-ways-to-stay-warm-in-winter/
> note the single '/', when I need '//'
>
> Is there any way to handle it?

http://nginx.org/r/merge_slashes

--
Maxim Dounin
http://nginx.org/

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: nginx removes double slashes

Gregory Edigarov
On 12/29/2014 06:00 PM, Maxim Dounin wrote:

> Hello!
>
> On Mon, Dec 29, 2014 at 01:04:06PM +0200, Gregory Edigarov wrote:
>
>> Hello everybody,
>>
>> perhaps I am doing something wrong:
>>
>>          location /njs/ {
>>                  rewrite /njs/(.*)$ /$1 break;
>>                  proxy_redirect off;
>>                  proxy_set_header Host $http_host;
>>                  proxy_set_header X-Real-IP $remote_addr;
>>                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>                  proxy_set_header X-Forwarded-Proto $scheme;
>>                  proxy_pass <a href="http://localhost:4006;">http://localhost:4006;
>>
>>          }
>> calling this
>> http://[hostname]/facebook/bitly/http%3A%2F%2F[hostname]%2Fbeth-buczynski%2Fdiy-ways-to-stay-warm-in-winter%2F
>>
>> and I definitely see that to my application it comes like:
>> http:/[hostname]/beth-buczynski/diy-ways-to-stay-warm-in-winter/
>> note the single '/', when I need '//'
>>
>> Is there any way to handle it?
> http://nginx.org/r/merge_slashes
Thank you. Just an  unlucky name for the option )))
I thought it's "preserve_slashes" and didn't find it.

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx