Re: Allow, deny и error_page 403

Daniil dan at onliner.by
Thu Sep 13 11:40:40 UTC 2012


Спасибо!

По логике вашего конфига разобрался. Не хватало директивы "allow all". В
итоге получился такой сниппет, который можно включить в любой server {...}:

allow 1.2.3.0/24;
deny all;

error_page 403 = @maint;
location @maint {
    allow all;
    proxy_set_header maint.server.com;
    proxy_pass http://main.server.com;
}



13 сентября 2012 г., 14:27 пользователь Alexey V. Karagodov <
kav at karagodov.name> написал:

> у меня работает вот так:
>
> www:~ # cat /opt/nginx/conf/include/location/error_page_lite
>  location @error_page_403 {
>  include  include/template/no-logging;
>  satisfy  any;
>  allow    all;
>  root     /local/www/vhosts/service/error;
>  try_files        /$host/403.html /$host/index.html /403.html /index.html
> =403;
>  }
>  location @error_page_497 {
>  include  include/template/no-logging;
>  root     /dev/null;
>  rewrite  ^       https://$host$request_uri?      permanent;
>  }
>  location @error_page_lite {
>  include  include/template/no-logging;
>  root     /local/www/vhosts/service/error;
>  try_files        /$host/index.html /index.html =404;
>  }
> www:~ #
>
>
> On 13.09.2012, at 14:48, Daniil <dan at onliner.by> wrote:
>
> Здравствуйте,
>
> При проведении технических работ на сайте обычно пользовались следующей
> конструкцией:
>
> allow 1.2.3.0/24;
> deny all;
>
> потом заходили с 1.2.3.0/24 и тестировали. Все остальные посетители в это
> время видели "403 Forbidden".
> Затем решили добавить страницу "Сайт временно недоступен. Извините..."
>
> При добавлении строк:
>
> error_page 403 = @maint;
> location @maint {
>     proxy_set_header maint.server.com;
>     proxy_pass http://maint.server.com;
> }
>
> nginx все равно возвращает "403 forbidden".
>
> Однако, если сделать например так:
>
> location @maint {
>     return 302 http://maint.server.com;
> }
>
> то происходит редирект.
>
> Скажите, в чем ошибка? Или это особенность реализации директивы deny и
> error_page?
>
> Версия nginx 1.3.6
> _______________________________________________
> nginx-ru mailing list
> nginx-ru at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>
>
>
> _______________________________________________
> nginx-ru mailing list
> nginx-ru at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>



-- 
С уважением,
Даниил Болсун
системный администратор
Onliner.by
тел/факс. +375 17 2271696
тел. +375 29 7755080
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-ru/attachments/20120913/677b624c/attachment-0001.html>


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