Php allow url fopen off

enable allow_url_fopen : Easy way to access remote data !!

The allow_url_fopen helps to access data from remote servers or websites.

Many times, hosting providers turn off the use of allow_url_fopen function as it can compromise the security of the website.

At Bobcares, we often get requests from our customers to enable allow_url_fopen as part of our Server Management Services.

Today, let’s get into the details on how our Support Engineers enable allow_url_fopen in different cases.

Why enable allow_url_fopen?

The allow_url_fopen refers to a PHP directive, which retrieves data from remote servers or websites. Our Support Engineers enable it from the custom/default PHP file according to the requirement.

Usually, hackers make use of this function to retrieve data from remote servers and do malicious acts. This PHP directiv e is always made disabled in the shared server. Thus, the shared server contains lots of domains, we always keep this as disabled to avoid high-security risk.

The following command checks whether the allow_url_fopen is On or Off.

grep allow_url_fopen /usr/local/lib/php.ini

According to the php.ini file location, there will be a slight variation in the actual command.

How to enable allow_url_fopen?

At Bobcares, where we have more than a decade of expertise in managing servers, we see many customers requesting to enable allow_url_fopen.

Now, let’s see how our Support Engineers enable allow_url_fopen by various methods according to the requirement of the user.

You can enable this via different methods.

1. Enabling for a unique website.

Quite often, customers approach us to enable this directive for unique websites (hosted in shared servers). In such cases, we help the customer by enabling it by creating a custom php.ini file under the public_html folder of the website.

According to the PHP handler used in the server, the file to edit the allow_url_fopen will vary.

Читайте также:  Import class in class css

a) Editing php.ini file

1. Initially, we log in to the server.
2. After that, we create a custom php.ini file and edit it using vim editor. Here, the allow_url_fopen will be set as disabled(off) for default. So to enable this, we edit this file and add

3. Then we save the php.ini file after changing allow_url_fopen to On

4. Finally, we restart the Apache service using

5. Further, we verify it using the info page under the user’s website.

https://your_domain/phpinfo.php

enable allow_url_fopen

b) Altering .htaccess file

In addition to this, when PHP runs as a DSO module, we enable allow_url_fopen by altering the .htaccess file. We added the following code to

php_value allow_url_fopen On

After altering we saved the file. This, in turn, enabled the allow_url_fopen.

2. Enabling allow_url_fopen for a server

Recently another customer who was having a dedicated server approached us to enable allow_url_fopen. We assisted the customer by editing the inbuilt php.ini file for enabling allow_url_fopen.

The path of the php.ini file varies according to easyapache 3 servers and easyapache 4 servers.

1. Initially, we logged into the server via SSH as root access.

2. Then using the php –ini command, we identified the path of default php.ini in the server.

In easyapache 3 servers the path is:

In easyapache 4 servers (with php version 5.6) the path is:

/opt/cpanel/ea-php56/root/etc/php.ini

3. After that, we edited the directive in php.ini file using vim editor.

4. Finally, restart the webserver.

Enabling via WHM

In addition, for the same case, we also enable allow_url_fopen for a server via WHM.

1. We signed up to WHM panel.

2. Then searched for MultiPHP INI Editor

3. After that we Selected Editor Mode and then selected the php version in Edit the INI settings of a PHP version

4. In that we searched allow_url_fopen, made it as On as follows below:

5 Finally, saved the changes.

For making the changes effective we restarted the Apache server.

[Need assistance to enable allow_url_fopen? We’ll help you.]

Conclusion

In short, the allow_url_fopen refers to a PHP directive, which retrieves data from remote servers or websites. We can enable this via editing the php.ini, .htaccess, or via WHM interface and so on. Today, we saw how our Support Engineers enabled the allow_url_fopen using different methods.

Читайте также:  Javascript на айфон для чего

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

Источник

Первичная настройка обеспечения безопасности в VM-Bitrix 7.2.*

Квест по первичной настройке обеспечения безопасности в VM-Bitrix 7.2.2

На других ветках форума по данному вопросу отправляют в ТП хостинг провайдера, но в случае администрирования VM мы сами себе хостинг провайдеры .

GO!
Запускаем в админке сканер безопасности и получаем такой ответ:

1) Разрешено чтение файлов по URL (URL wrappers)
+ вопрос , будет ли работать Я ндекс метрика и Гугл аналитика, Market Place с этой настройкой?
Ведь эта настройка сделает запрет подключения сайта к удалённым страницам, скриптам.

Моя п опытка решить задачу:

Открываем php.ini из командной строки Linux:

Значение allow_url_fopen = On меняем на Off

systemctl restart httpd.service

Иду в админку проверять, предупреждение не пропало, а значит не работает. Ок, пожалуй укажу еще данный параметр в файле .htaccess сайта, открываем его из командной строки:

nano /home/bitrix/www/.htaccess

Значение php_flag allow_url_fopen = Пробовал поставить значение 0 (ноль) и Off

Пробовал установить сюда:

Сканер безопасности сообщил что вопрос актуален .
Подскажите, как пофиксить?

Открываю php.ini из командной строки Linux:

Ищу строки display_errors , вижу что по умолчанию параметр соответствует предложенному решению, тоесть значение Off либо строки закомментированы и не обрабатываются

Поделитесь пожалуйста опытом

Мои посты и вопросы кажутся полезными? Плюсани + мне под аватаркой 😉

  1. Зайти на сервер SFTP клиентом или по SSH c root правами
  2. Открыть конфигурационный файл /etc/php.d/bitrixenv.ini
  3. Найти allow_url_fopen и изменить значение на Off
  4. Перезагрузить Apache. В командной строке выполните service httpd restart
  5. Проверить, что директива изменила значение можно в /bitrix/admin/phpinfo.php
Цитата
написал:
Зайти на сервер SFTP клиентом или по SSH c root правами
Открыть конфигурационный файл /etc/php.d/bitrixenv.ini
Найти allow_url_fopen и изменить значение на Off
Перезагрузить Apache. В командной строке выполните service httpd restart
Проверить, что директива изменила значение можно в /bitrix/admin/phpinfo.php

Если allow_url_include off — то allow_url_fopen вполне можно оставить в on. Никакой угрозы безопасности в этом нет.

Продукты

Управление сайтом

Битрикс24

Интернет-магазин + CRM

Решения

Для интернет-магазинов

Каталог готовых решений

Внедрение

Выбрать партнера

Проверить партнера

Стать партнером

1С-Битрикс http://www.1c-bitrix.ru Общие вопросы info@1c-bitrix.ru Приобретение и лицензирование продуктов : sales@1c-bitrix.ru Маркетинг/мероприятия/PR marketing@1c-bitrix.ru Партнерская программа partners@1c-bitrix.ru Мы работаем с 10:00 до 19:00 по московскому времени. Офис в Москве 127287 Россия Московская область Москва 2-я Хуторская улица дом 38А строение 9 Офис в Калининграде +7 (4012) 51-05-64 Офис в Калининграде 236001 Россия Калининградская область Калининград Московский проспект 261 Офис в Киеве ukraine@1c-bitrix.ru Телефон в Киеве +3 (8044)221-55-33 Офис в Киеве 01033 Украина Калининградская область Киев улица Шота Руставели 39/41 офис 1507

Читайте также:  Php проверить целостность файла

Контент для лиц от 16 лет и старше

© 2001-2023 «Битрикс», «1С-Битрикс». Работает на 1С-Битрикс: Управление сайтом. Политика конфиденциальности

Источник

Php allow url fopen off

Поведение этих функций зависит от установок в php.ini .

Директивы конфигурации файловой системы и потоков

Имя По умолчанию Место изменения Список изменений
allow_url_fopen «1» PHP_INI_SYSTEM
allow_url_include «0» PHP_INI_SYSTEM Объявлена устаревшей с версии PHP 7.4.0.
user_agent NULL PHP_INI_ALL
default_socket_timeout «60» PHP_INI_ALL
from «» PHP_INI_ALL
auto_detect_line_endings «0» PHP_INI_ALL Объявлена устаревшей с версии PHP 8.1.0.
sys_temp_dir «» PHP_INI_SYSTEM

Краткое разъяснение конфигурационных директив.

Данная директива включает поддержку обёрток URL (URL wrappers), которые позволяют работать с объектами URL как с обычными файлами. Обёртки, доступные по умолчанию, служат для работы с удалёнными файлами с использованием ftp или http протокола. Некоторые модули, например, zlib, могут регистрировать собственные обёртки.

Эта опция позволяет использование обёрток fopen, которые поддерживают работу с URL, в функциях include , include_once , require , require_once .

Замечание:

Эта опция требует включения опции allow_url_fopen.

Устанавливает отсылаемую PHP строку «User-Agent».

Значение времени ожидания по умолчанию (в секундах) для потоков, использующих сокеты. Отрицательное значения означает бесконечное время ожидания.

Адрес email, используемый в соединениях FTP без авторизации, а также в качестве значения заголовка From в HTTP соединениях при использовании ftp и http обёрток, соответственно.

Когда данная директива включена, PHP проверяет данные, получаемые функциями fgets() и file() с тем, чтобы определить способ завершения строк (Unix, MS-Dos или Macintosh).

Данная директива позволяет PHP взаимодействовать с системами Macintosh, однако, по умолчанию эта директива выключена, поскольку при её использовании возникает (несущественная) потребность в дополнительных ресурсах для определения символа окончания первой строки, а также потому, что программисты, использующие в системах Unix символы возврата каретки в качестве разделителей, столкнутся с обратно-несовместимым поведением PHP.

Источник

Оцените статью