<div dir="ltr"><div>Можно поÑле if делать внутренний редирект на другой локейшен (еÑли, конечно, в вашем Ñлучае нет какой-то Ñложной дальнейшей обработки и Ð²Ð°Ñ Ð¸Ð½Ñ‚ÐµÑ€ÐµÑует только то, что запиÑано в location / ) при помощи error_page. То еÑть:</div><div><br></div><div>error_page 420 = @special_location;</div><div><br></div><div>location /test/lfs_lock_test.git/info/lfs/locks{<br> if ( $args ~ "lockservice=true" ) {<br> return 420;<br> }<br> rewrite ^/test/lfs_lock_test.git/(.*) /$1 break;<br> proxy_pass <a href="https://localhost:5002">https://localhost:5002</a>;<br> access_log  /var/log/gitlab/nginx/lfs_lock_access.log gitlab_access;<br> error_log  /var/log/gitlab/nginx/lfs_lock_error.log debug;<br>}<br></div><div dir="ltr"><div><br></div><div>location @special_location {</div><div>  proxy_cache off;<br>  proxy_pass  <a href="http://gitlab-workhorse">http://gitlab-workhorse</a>;<br></div><div>}</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">пн, 27 июл. 2020 г. в 09:16, Роман Буренков <<a href="mailto:panzercheg@gmail.com">panzercheg@gmail.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><br></div><div>Ð ÐºÐ°ÐºÐ°Ñ Ð±Ñ‹Ð»Ð° бы более Ð¿Ñ€Ð°Ð²Ð¸Ð»ÑŒÐ½Ð°Ñ Ð»Ð¾Ð³Ð¸ÐºÐ°? Я изначально хотел Ñделать 2 правила Ñ (?)(?!) но почему в таком regex`е у Ð¼ÐµÐ½Ñ Ð²ÑÑ‘ равно не тот url, что Ñ Ñ…Ð¾Ñ‚ÐµÐ» проÑачивалÑÑ Ð² location ( location ~ (?^/.*.git/info/lfs/locks$)(?!^.*&lockservice=true$))</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">вÑ, 26 июл. 2020 г. в 15:00, <<a href="mailto:nginx-ru-request@nginx.org" target="_blank">nginx-ru-request@nginx.org</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">СообщениÑ, предназначенные Ð´Ð»Ñ ÑпиÑка<br>
раÑÑылки nginx-ru, отправлÑйте по адреÑу<br>
    <a href="mailto:nginx-ru@nginx.org" target="_blank">nginx-ru@nginx.org</a><br>
<br>
Ð”Ð»Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñ Ð¿Ð°Ñ€Ð°Ð¼ÐµÑ‚Ñ€Ð¾Ð² подпиÑки или<br>
отпиÑки иÑпользуйте веб-Ñтраницу<br>
    <a href="http://mailman.nginx.org/mailman/listinfo/nginx-ru" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-ru</a><br>
или отправьте пиÑьмо, в теле или теме<br>
которого будет Ñлово 'help', по адреÑу<br>
    <a href="mailto:nginx-ru-request@nginx.org" target="_blank">nginx-ru-request@nginx.org</a><br>
<br>
ÐÐ´Ñ€ÐµÑ Ð°Ð´Ð¼Ð¸Ð½Ð¸Ñтратора Ñтого ÑпиÑка<br>
раÑÑылки:<br>
    <a href="mailto:nginx-ru-owner@nginx.org" target="_blank">nginx-ru-owner@nginx.org</a><br>
<br>
При ответе, пожалуйÑта, измените тему<br>
пиÑьма на более Ñодержательную чем "Re:<br>
Содержание дайджеÑта ÑпиÑка раÑÑылки<br>
nginx-ru..."<br>
Ð’ Ñтом номере:<br>
<br>
  1. Возможно ли оÑтановить<br>
   выполнение правил внутри<br>
   location/выйти из location (Роман Буренков)<br>
  2. Re: Возможно ли оÑтановить<br>
   выполнение правил внутри<br>
   location/выйти из location (Сергей Олегович)<br>
<br><br><br>---------- Forwarded message ----------<br>From: "Роман Буренков" <<a href="mailto:panzercheg@gmail.com" target="_blank">panzercheg@gmail.com</a>><br>To: <a href="mailto:nginx-ru@nginx.org" target="_blank">nginx-ru@nginx.org</a><br>Cc: <br>Bcc: <br>Date: Sun, 26 Jul 2020 12:11:20 +0300<br>Subject: Возможно ли оÑтановить выполнение правил внутри location/выйти из location<br><div dir="ltr"><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px">Я иÑпользую gitlab 12 СE ( 12.9.2 (ac5568eb5d8) ) и nginx из поÑтавки gitlab (nginx 1.16.1 sha256:f11c2a6d )</span><div><font color="#242729" face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size:15px"><br></span></font></div><div><font color="#242729" face="Arial, Helvetica Neue, Helvetica, sans-serif"><span style="font-size:15px">куÑок моего location Ñ Ð¿Ñ€Ð°Ð²Ð¸Ð»Ð°Ð¼Ð¸:<br></span></font><div><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit">location /test/lfs_lock_test.git/info/lfs/locks{
if ( $args ~ "lockservice=true" ) {
return 404;
}
rewrite ^/test/lfs_lock_test.git/(.*) /$1 break;
proxy_pass <a href="https://localhost:5002" target="_blank">https://localhost:5002</a>;
access_log /var/log/gitlab/nginx/lfs_lock_access.log gitlab_access;
error_log /var/log/gitlab/nginx/lfs_lock_error.log debug;
}</code></pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px;color:rgb(36,39,41)">Ñ Ñ…Ð¾Ñ‡Ñƒ обрабатывать вÑе запроÑÑ‹ на ^.*.git/info/lfs/locks внутри location,<br>только еÑли там не ÑодержитÑÑ lockservice=true в URI, в Ñто Ñлучае, <br>проÑто выйти из location ( без 404 ) ,Ñ‚.к. в файле, который Ñ Ð¿Ñ€Ð°Ð²Ð»ÑŽ <br>( /var/opt/gitlab/nginx/conf/<span style="font-family:arial,sans-serif;background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;white-space:normal">gitlab-http.conf ) еÑть в Ñ‚.ч. и такое:</span></pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px;color:rgb(36,39,41)"><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit"> location / {
proxy_cache off;
proxy_pass <a href="http://gitlab-workhorse" target="_blank">http://gitlab-workhorse</a>;
}</code></pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px">Ñ‚.е. еÑли еÑть lockservice=true в URI, то не делать proxy_pass и в принципе не применÑть правила из моего location
</pre>
</pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit">
</code></pre></div></div></div>
<br><br><br>---------- Forwarded message ----------<br>From: "Сергей Олегович" <<a href="mailto:shadow.tehb@gmail.com" target="_blank">shadow.tehb@gmail.com</a>><br>To: <<a href="mailto:nginx-ru@nginx.org" target="_blank">nginx-ru@nginx.org</a>><br>Cc: <br>Bcc: <br>Date: Sun, 26 Jul 2020 12:28:43 +0300<br>Subject: Re: Возможно ли оÑтановить выполнение правил внутри location/выйти из location<br><u></u>
<div>
<div dir="auto">
<div dir="auto">Можно в if заÑунуть rewrite ... last; Тогда поÑле Ð²Ñ‹Ð¿Ð¾Ð»Ð½ÐµÐ½Ð¸Ñ ÑƒÑÐ»Ð¾Ð²Ð¸Ñ Ð±ÑƒÐ´ÐµÑ‚ Ñовершён выход из Ñтого location и поиÑк нового в ÑоответÑтвии Ñ Ð¸Ð·Ð¼ÐµÐ½ÐµÐ½Ð¸Ñми. Ðо мне Ñходу видÑÑ‚ÑÑ Ð¿Ñ€Ð¾Ð±Ð»ÐµÐ¼Ñ‹, Ñ‚.к. изначально логика поÑтроена неверно. </div><div dir="auto"><br></div>
<div id="gmail-m_6156384380826989527gmail-m_-3352198298135230484aqm-original" style="color:black">
<div>
<div style="color:black">
<p style="color:black;font-size:10pt;font-family:sans-serif;margin:8pt 0px">Роман Буренков <<a href="mailto:panzercheg@gmail.com" target="_blank">panzercheg@gmail.com</a>> 26 Ð¸ÑŽÐ»Ñ 2020 г. 12:11:41 напиÑал:</p>
<blockquote type="cite" class="gmail_quote" style="margin:0px 0px 0px 0.75ex;border-left:1px solid rgb(128,128,128);padding-left:0.75ex">
<div dir="ltr"><span style="color:rgb(36,39,41);font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;font-size:15px">Я иÑпользую gitlab 12 СE ( 12.9.2 (ac5568eb5d8) ) и nginx из поÑтавки gitlab (nginx 1.16.1 sha256:f11c2a6d )</span><div><span style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;color:rgb(36,39,41)"><span style="font-size:15px"><br></span></span></div><div><span style="font-family:Arial,"Helvetica Neue",Helvetica,sans-serif;color:rgb(36,39,41)"><span style="font-size:15px">куÑок моего location Ñ Ð¿Ñ€Ð°Ð²Ð¸Ð»Ð°Ð¼Ð¸:<br></span></span><div><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit">location /test/lfs_lock_test.git/info/lfs/locks{
if ( $args ~ "lockservice=true" ) {
return 404;
}
rewrite ^/test/lfs_lock_test.git/(.*) /$1 break;
proxy_pass <a href="https://localhost:5002" target="_blank">https://localhost:5002</a>;
access_log /var/log/gitlab/nginx/lfs_lock_access.log gitlab_access;
error_log /var/log/gitlab/nginx/lfs_lock_error.log debug;
}</code></pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px;color:rgb(36,39,41)">Ñ Ñ…Ð¾Ñ‡Ñƒ обрабатывать вÑе запроÑÑ‹ на ^.*.git/info/lfs/locks внутри location,<br>только еÑли там не ÑодержитÑÑ lockservice=true в URI, в Ñто Ñлучае, <br>проÑто выйти из location ( без 404 ) ,Ñ‚.к. в файле, который Ñ Ð¿Ñ€Ð°Ð²Ð»ÑŽ <br>( /var/opt/gitlab/nginx/conf/<span style="font-family:arial,sans-serif;background-color:transparent;font-style:inherit;font-variant-ligatures:inherit;font-variant-caps:inherit;white-space:normal">gitlab-http.conf ) еÑть в Ñ‚.ч. и такое:</span></pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px;color:rgb(36,39,41)"><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit"> location / {
proxy_cache off;
proxy_pass <a href="http://gitlab-workhorse" target="_blank">http://gitlab-workhorse</a>;
}</code></pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px">Ñ‚.е. еÑли еÑть lockservice=true в URI, то не делать proxy_pass и в принципе не применÑть правила из моего location
</pre>
</pre><pre style="margin-top:0px;margin-bottom:1em;padding:12px 8px;border:0px;font-variant-numeric:inherit;font-variant-east-asian:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;font-size:13px;vertical-align:baseline;box-sizing:inherit;width:auto;max-height:600px;overflow:auto;border-radius:3px;color:rgb(36,39,41)"><code style="margin:0px;padding:0px;border:0px;font-style:inherit;font-variant:inherit;font-weight:inherit;font-stretch:inherit;line-height:inherit;font-family:Consolas,Menlo,Monaco,"Lucida Console","Liberation Mono","DejaVu Sans Mono","Bitstream Vera Sans Mono","Courier New",monospace,sans-serif;vertical-align:baseline;box-sizing:inherit;background-color:transparent;white-space:inherit">
</code></pre></div></div></div>
<div>_______________________________________________</div>
<div>nginx-ru mailing list</div>
<div><a href="mailto:nginx-ru%40nginx.org" target="_blank">nginx-ru@nginx.org</a></div>
<div><a href="http://mailman.nginx.org/mailman/listinfo/nginx-ru" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-ru</a></div>
</blockquote>
</div>
</div>
</div><div dir="auto"><br></div>
</div></div>
_______________________________________________<br>
nginx-ru mailing list<br>
<a href="mailto:nginx-ru@nginx.org" target="_blank">nginx-ru@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-ru" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-ru</a></blockquote></div></div>
_______________________________________________<br>
nginx-ru mailing list<br>
<a href="mailto:nginx-ru@nginx.org" target="_blank">nginx-ru@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-ru" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-ru</a></blockquote></div></div>