tell nginx to stay inside same location?

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

tell nginx to stay inside same location?

Gregory Edigarov
Hello,

is that possible to tell nginx to stay inside the same location after
rewrite rule is done?

i.e. I have:

location  /njs/ {
     proxy_pass <a href="http://localhost:5501;">http://localhost:5501;
......
}

now, if i need to cut off /njs/ part, i added the following:
location /njs/ {
     rewrite /njs(.*) $1;
     proxy_pass <a href="http://localhost:5501;">http://localhost:5501;
..........
   }

but, that doesn't work, because my uri has changed and nginx goes to the
default location, which I don't need.

what could I do in this situation?

--
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: tell nginx to stay inside same location?

Edho Arief-2
On Thu, Jul 30, 2015 at 11:57 PM, Gregory Edigarov <[hidden email]> wrote:

> Hello,
>
> is that possible to tell nginx to stay inside the same location after
> rewrite rule is done?
>
> i.e. I have:
>
> location  /njs/ {
>     proxy_pass <a href="http://localhost:5501;">http://localhost:5501;
> ......
> }
>
> now, if i need to cut off /njs/ part, i added the following:
> location /njs/ {
>     rewrite /njs(.*) $1;
>     proxy_pass <a href="http://localhost:5501;">http://localhost:5501;
> ..........
>   }
>
> but, that doesn't work, because my uri has changed and nginx goes to the
> default location, which I don't need.
>
> what could I do in this situation?
>

if only you have read the documentation...

http://nginx.org/r/proxy_pass

...
When the URI is changed inside a proxied location using the rewrite
directive, and this same configuration will be used to process a
request (break):

location /name/ {
    rewrite    /name/([^/]+) /users?name=$1 break;
    proxy_pass http://127.0.0.1;
}

In this case, the URI specified in the directive is ignored and the
full changed request URI is passed to the server.
...

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

Re: tell nginx to stay inside same location?

Gregory Edigarov


On 07/30/2015 06:02 PM, Edho Arief wrote:

> On Thu, Jul 30, 2015 at 11:57 PM, Gregory Edigarov <[hidden email]> wrote:
>> Hello,
>>
>> is that possible to tell nginx to stay inside the same location after
>> rewrite rule is done?
>>
>> i.e. I have:
>>
>> location  /njs/ {
>>      proxy_pass <a href="http://localhost:5501;">http://localhost:5501;
>> ......
>> }
>>
>> now, if i need to cut off /njs/ part, i added the following:
>> location /njs/ {
>>      rewrite /njs(.*) $1;
>>      proxy_pass <a href="http://localhost:5501;">http://localhost:5501;
>> ..........
>>    }
>>
>> but, that doesn't work, because my uri has changed and nginx goes to the
>> default location, which I don't need.
>>
>> what could I do in this situation?
>>
> if only you have read the documentation...
>
> http://nginx.org/r/proxy_pass
>
> ...
> When the URI is changed inside a proxied location using the rewrite
> directive, and this same configuration will be used to process a
> request (break):
>
> location /name/ {
>      rewrite    /name/([^/]+) /users?name=$1 break;
>      proxy_pass http://127.0.0.1;
> }
>
> In this case, the URI specified in the directive is ignored and the
> full changed request URI is passed to the server.
> ...
>
thank you very very much.
I've read the docs, but skipped the break completely, somehow.

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

Re: tell nginx to stay inside same location?

Igor Sysoev-2
In reply to this post by Gregory Edigarov
On 30 Jul 2015, at 17:57, Gregory Edigarov <[hidden email]> wrote:

> Hello,
>
> is that possible to tell nginx to stay inside the same location after rewrite rule is done?
>
> i.e. I have:
>
> location  /njs/ {
>    proxy_pass <a href="http://localhost:5501;">http://localhost:5501;
> ......
> }
>
> now, if i need to cut off /njs/ part, i added the following:
> location /njs/ {
>    rewrite /njs(.*) $1;
>    proxy_pass <a href="http://localhost:5501;">http://localhost:5501;
> ..........
>  }
>
> but, that doesn't work, because my uri has changed and nginx goes to the default location, which I don't need.
>
> what could I do in this situation?

Just add slash in upstream:

location  /njs/ {
   proxy_pass http://localhost:5501/;
   ......
}


--
Igor Sysoev
http://nginx.com

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

Re: tell nginx to stay inside same location?

Andrii Balytskyi
In reply to this post by Gregory Edigarov
To produce a longer message brief that check out is just not completed
but in relation to face in addition to instance a finish. That check out
is often as customary interested in shots for the look at becoming more
common earlier than it is always visually fantastic. Which means people
will present picture and many more graphics belonging to the view
someday, nevertheless hardly right this moment. Whatever we can easily
reassure a person is actually that your portion is normally remarkable
including a sharp proof associated with genital herpes virus treatments
obtain in cases where it is easy to devote the particular money intended
for this acquire.
http://www.waxwatchreplicas.co.uk
http://www.waxwatchreplicas.co.uk/replica-breitling-watches-sale-for-uk.html
http://www.waxwatchreplicas.co.uk/replica-cartier-watches-sale-for-uk.html

--
Posted via http://www.ruby-forum.com/.

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