Re: Организация локейшенов

Denis F. Latypoff latypoff на yandex.ru
Пн Май 28 15:03:13 UTC 2012



28.05.2012, 21:58, "c350" <nginx-forum at nginx.us>:
> Здравствуйте.
>
> Как более грамотно написать?
>
> Вариант 1):
> set $backend 'http://127.0.0.10:80';
> location ~* /location1 {
>         rewrite ^ /backend_scripts/path/to/script1 break;
>         proxy_pass $backend$uri$is_args$args;
> }
> ...
> location ~* /locationN {
>         rewrite ^ /backend_scripts/path/to/scriptN break;
>         proxy_pass $backend$uri$is_args$args;
> }
>
> Вариант 2):
> set $backend 'http://127.0.0.10:80';
> location ^~ /backend_scripts/ {
>         proxy_pass $backend$uri$is_args$args;
> }
> location ~* /location1 {
>         rewrite ^ /backend_scripts/path/to/script1 last;
> }
> ...
> location ~* /locationN {
>         rewrite ^ /backend_scripts/path/to/scriptN last;
> }
>
> Подозреваю, что более правильный
> вариант1, но хотелось бы услышать
> мнение знающих людей.
>

location ~* /location\d+ {
    rewrite /location(\d+) /backend_scripts/path/to/script$1 break;
    proxy_pass http://127.0.0.10;
}

-- 
br, Denis F. Latypoff.



Подробная информация о списке рассылки nginx-ru