Доброго дня, уважаемые разработчики «1С-Битрикс: Веб-окружение» - Linux!
Сначала маленький баг-репорт, введя даже "[B]n[/B]" на вопрос установки пароля, мы все равно вынуждены его установить. Пустой пароль также не воспринимается, поэтому приходится в итоге что-то вводить.
[CODE][root@testdedic0 ~]# wget http://repos.1c-bitrix.ru/yum/bitrix-env.sh
--2017-02-13 23:31:08-- http://repos.1c-bitrix.ru/yum/bitrix-env.sh
Resolving repos.1c-bitrix.ru (repos.1c-bitrix.ru)... 54.230.11.199, 54.230.11.166, 54.230.11.164, ...
Connecting to repos.1c-bitrix.ru (repos.1c-bitrix.ru)|54.230.11.199|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15843 (15K) [application/x-sh]
Saving to: ‘bitrix-env.sh’
100%[===================================================================================================================================>] 15 843 --.-K/s in 0s
2017-02-13 23:31:08 (875 MB/s) - ‘bitrix-env.sh’ saved [15843/15843]
[root@testdedic0 ~]# chmod +x bitrix-env.sh
[root@testdedic0 ~]# ./bitrix-env.sh
====================================================================
Bitrix Environment for Linux installation script.
Yes will be assumed to answers, and will be defaulted.
'n' or 'no' will result in a No answer, anything else will be a yes.
This script MUST be run as root or it will fail
====================================================================
Upd ate system. Please wait.
EPEL repository is already configured on the server.
Getting configuration REMI repository. Please wait.
Configuration REMI repository is completed.
# MariaDB 5.5 CentOS repository list - created 2016-07-14 08:15 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Configuration MariaDB repository is completed.
Getting configuration Bitrix repository. Please wait.
Configuration Bitrix repository is completed.
Upd ate system. Please wait.
Install php packages. Please wait.
Install bitrix-env package. Please wait.
Do you want to set a password for root user in MySQL service?(Y|n): n
Do you want to set a password for root user in MySQL service?(Y|n): n
Enter root password:
Re-enter root password: Enter root password:
Re-enter root password: Bitrix Environment installation is completed.
[/CODE][B]Ну а теперь о главной боли, как именно производится передача заголовков о том, что сайт работает на SSL.[/B]
А именно, на сервере по умолчанию стоит стандартный модуль remoteip [URL=https://httpd.apache.org/docs/current/mod/mod_remoteip.html]https://httpd.apache.org/docs/current/mod/mod_remoteip.html[/URL] который мало, что умеет.
[CODE][root@testdedic0 ~]# apachectl -M | grep -E 'remoteip|rpaf'
remoteip_module (shared)
[/CODE]И видимо по данной причине рождаются костыли вида:[CODE][root@testdedic0 ~]# cat /etc/nginx/bx/site_enabled/ssl.s1.conf
# Default SSL certificate enabled website
server {
listen 443 default_server http2;
server_name _;
# Enable SSL connection
include bx/conf/ssl.conf;
server_name_in_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host:443;
proxy_set_header HTTPS YES;
se t $proxyserver "http://127.0.0.1:8888";
se t $docroot "/home/bitrix/www";
index index.php;
root /home/bitrix/www;
# Include parameters common to all websites
include bx/conf/bitrix.conf;
# Include server monitoring API's
include bx/server_monitor.conf;
}
[/CODE]А именно строчки[CODE] proxy_set_header Host $host:443;
proxy_set_header HTTPS YES;
[/CODE]Что выглядит очень дико, более того, выглядит дико даже для самой CMS, а также приводит в уныние наших клиентов и нас в особенности, так как с этим приходится как-то жить и работать.
[IMG WIDTH=1076 HEIGHT=687]http://storage7.static.itmages.com/i/17/0213/h_1487027593_2885983_e2529524ac.png[/IMG]
Ссылка на изображение [URL=http://storage7.static.itmages.com/i/17/0213/h_1487027593_2885983_e2529524ac.png]http://storage7.static.itmages.com/i/17/0213/h_1487027593_2885983_e2529524ac.png[/URL]
А теперь посмотрим на здоровые заголовки
[IMG WIDTH=1076 HEIGHT=687]http://storage1.static.itmages.com/i/17/0213/h_1487029308_5517353_e9b0877680.png[/IMG]
Ссылка на изображение [URL=http://storage1.static.itmages.com/i/17/0213/h_1487029308_5517353_e9b0877680.png]http://storage1.static.itmages.com/i/17/0213/h_1487029308_5517353_e9b0877680.png[/URL]
[B]Как к ним прийти?!
[/B]
Воспользуемся замечательнейшим модулем [URL=https://github.com/gnif/mod_rpaf]https://github.com/gnif/mod_rpaf[/URL] который протестирован в бою и [B]успешно нами эксплуатируется в продакшене на нескольких тысячах серверах, т.е. модуль стабилен чуть более, чем полностью.[/B]
1. Настройка веб-сервера Apache2
Рассмотрим сборку данного модуля, которая выполняется всего в пару команд:
[CODE]yum groupinstall "Development Tools"
yum install httpd-devel
wget -O /tmp/mod_rpaf.c https://raw.githubusercontent.com/gnif/mod_rpaf/stable/mod_rpaf.c
apxs -c -i /tmp/mod_rpaf.c
[/CODE]Далее прописываем конфиг[CODE][root@testdedic0 ~]# cat /etc/httpd/bx/custom/rpaf.conf
LoadModule rpaf_module modules/mod_rpaf.so
RPAF_Enable On
RPAF_ProxyIPs 127.0.0.1 78.46.76.2
RPAF_SetHostName On
RPAF_SetHTTPS On
RPAF_SetPort On
RPAF_ForbidIfNotProxy Off
[/CODE]И не забываем выключить remoteip в файле /etc/httpd/conf.modules.d/00-base.conf и удалить файл /etc/httpd/bx/conf/mod_rpaf.conf
На выходе получим[CODE][root@testdedic0 ~]# apachectl -M | grep -E 'remoteip|rpaf'
rpaf_module (shared)
[/CODE]Перезапускаем веб-сервер.
2. Настройка веб-сервера nginx.
В файле /etc/nginx/bx/site_enabled/ssl.s1.conf меняем строки
[CODE] proxy_set_header Host $host:443;
proxy_set_header HTTPS YES;
[/CODE]на[CODE] proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
[/CODE]В файле /etc/nginx/bx/site_enabled/s1.conf меняем строки[CODE] proxy_set_header Host $host:80;
[/CODE]на[CODE] proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;[/CODE]Перезапускаем веб-сервер nginx.
Готово.
В итоге еще и получим дублирующий блок
[CODE] proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
[/CODE]который можно унести в bx/conf/bitrix.conf
[B]В итоге?[/B]
Уважаемые разработчики! Пожалуйста, рассмотрите, протестируйте и внедрите данное решение в upstream. Битрикс-Окружение в любом случае имеет свой репозиторий и собранные кастомные пакеты, например тот же Nginx, и добавить еще 50Кб модуля rpaf не должно составить труда, но при этом Вы сделаете множество пользователей Вашего окружения чуточку счастливее.
Всем добра, спасибо за внимание.
С уважением и надеждой, что данное будет услышано, Ковальков Дмитрий
Технический отдел fastvps.ru