We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on Vesta 2.0 and expect to release it by the end of 2024. Read more about it: https://vestacp.com/docs/vesta-2-development
nginx+php-fpm ограничение на папку по IP
nginx+php-fpm ограничение на папку по IP
Всем привет.
Есть конфигурация nginx+php-fpm , Centos 7.2
Никак не могу применить ограничение на папку по IP для домена.
Запрет для всех работает:
Разрешение ну никак не хочет :( предлагает сохранить какие то файлы постоянно
Может кто подсобнет советом, интернет как то не помогает в данном случае.
Есть конфигурация nginx+php-fpm , Centos 7.2
Никак не могу применить ограничение на папку по IP для домена.
Запрет для всех работает:
SpoilerShow
location ~* ^/administrator/.+\.php {
deny all;
}
deny all;
}
SpoilerShow
location ~* ^/administrator/.+\.php {
allow Х.Х.Х.Х;
deny all;
}
allow Х.Х.Х.Х;
deny all;
}
Re: nginx+php-fpm ограничение на папку по IP
Блин ну неужели ни у кого такого не было ?
Перепробовал кучу различных модификаций строк .... deny работает, allow не работает. ^(((
Че ему надо не пойму.
Перепробовал кучу различных модификаций строк .... deny работает, allow не работает. ^(((
Че ему надо не пойму.
Re: nginx+php-fpm ограничение на папку по IP
Попробовал новую конфигурацию:
location ~* /administrator/. {
allow Х.Х.Х.Х;
deny all;
}
При нужном ИП предлагает скачать какой то сценарий, при неправильном ИП блокирует .... :((( Неужели у всех работает, запрет по ИП или все тупо юзают пароли и не парятся такими недоработками.
location ~* /administrator/. {
allow Х.Х.Х.Х;
deny all;
}
При нужном ИП предлагает скачать какой то сценарий, при неправильном ИП блокирует .... :((( Неужели у всех работает, запрет по ИП или все тупо юзают пароли и не парятся такими недоработками.
Re: nginx+php-fpm ограничение на папку по IP
Схема классическая, даже странно почему она у вас не сработала
Попробуйте вот так записать локейшен:
Попробуйте вот так записать локейшен:
Code: Select all
location ^~ /administrator {
allow 1.2.3.4;
deny all;
}
Re: nginx+php-fpm ограничение на папку по IP
Попробовал, все тоже самое, при совпадении ИП предлагает скачать сценарий пхп. Запрет работает.skurudo wrote:Схема классическая, даже странно почему она у вас не сработала
Попробуйте вот так записать локейшен:Code: Select all
location ^~ /administrator { allow 1.2.3.4; deny all; }
Конфигурация joomla, пытался вставлять в разные места конфига вроде тоже не помогает :(
Может надо в какое то определенное место вставлять?
Re: nginx+php-fpm ограничение на папку по IP
Может я не в то место ее впихиваю, подскажите в какую строку конфига жумла нужно ее вставить?skurudo wrote:Схема классическая, даже странно почему она у вас не сработала
Попробуйте вот так записать локейшен:
Re: nginx+php-fpm ограничение на папку по IP
А она может не сработать.skurudo wrote:Схема классическая, даже странно почему она у вас не сработала
Попробуйте вот так записать локейшен:Code: Select all
location ^~ /administrator { allow 1.2.3.4; deny all; }
Для /administrator она сработает, а /administrator/index.php будет обработан локейшеном location ~ [^/]\.php(/|$) или какой там.
Что бы ограничить доступ к папке по ip, нужно делать вложенный локейшн, обрабатывающий php.
Пример
Code: Select all
location ^~ /administrator/ {
allow 1.2.3.4/24;
allow 1.2.3.4/16;
deny all;
location ~ \php$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
...
...
}
}
Или пример в случае ТС
Code: Select all
location ~* ^/administrator/.+\.php {
allow Х.Х.Х.Х;
deny all;
// добавляем обработку php
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
...
...
}
}
Re: nginx+php-fpm ограничение на папку по IP
Спасиииибоооо человек !!!Stesh wrote:А она может не сработать.
Сколько сил потратилось на перечитывание этих всех гребаных мануалов по безопасности, joomla, nginx и прочей пурги. Сколько всякой информации я узнал за это время но ни в одном не встретил этого гениального решения.
Заработало елы палы, ну почему ..... ПОЧЕМУ этого нет в стандартном конфиге Joomla. Вот сто пудово все юзают пароли.
По существу, заработал почему только один вариант, второй не захотел:
Code: Select all
location ^~ /administrator/ {
allow х.х.х.х;
deny all;
location ~ \php$ {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9050;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
Теперь осталось освоить настройки nginxa по geo ip :)