
Собираем Nginx из исходного кода в Astra Linux с поддержкой OpenSSL 3.0.3
Доступной версией Nginx в Astra Linux является версия 1.14.1, но вам, возможно, вам может потребоваться свежая версия, на момент написания статьи это 1.20.2.
В репозитории Astra Linux находится на данный момент немного устаревшая версия библиотеки libssl-dev, версии 1.1.1k.
Мы будем сразу использовать новую версию ветки OpenSSL 3 (3.0.3), она будет поддерживаться до 7 сентября 2026.
К тому же у вас могут возникнуть проблемы со сборкой последней версии Nginx при использовании OpenSSL 1.1.1k.
Сегодня мы рассмотрим сборку из исходного кода web-сервера Nginx в Astra Linux с поддержкой OpenSSL 3.0.3.
Установка
Установим требуемые пакеты:
sudo apt update
sudo apt upgrade
sudo apt install build-essential git perl libperl-dev libgd3 libgd-dev libgeoip1 libgeoip-dev geoip-bin libxml2 libxml2-dev libxslt1.1 libxslt1-dev zlib1g-dev libssl1.0-dev libpcre2-dev libpcre2-posix0 mercurial wget libpcre3-dev
Загрузим исходный код с Mercural проекта:
cd ~ hg clone http://hg.nginx.org/nginx -r stable-1.20 ~/nginx
Для сборки нам потребуется свежая версия OpenSSL так как с версиями ветки 1 у меня возникли проблемы со сборкой Nginx.
Загрузка исходного кода OpenSSL 3.0.3
cd ~/nginx wget --no-check-certificate https://www.openssl.org/source/openssl-3.0.3.tar.gz
Проверим хэш загруженного фала:
echo 'ee0078adcef1de5f003c62c80cc96527721609c6f3bb42b7795df31f8b558c0b openssl-3.0.3.tar.gz' | tee openssl-3.0.3.tar.gz.sha256
sha256sum --check openssl-3.0.3.tar.gz.sha256
openssl-3.0.3.tar.gz: ЦЕЛ
Распакуем:
tar xvf openssl-3.0.3.tar.gz
Мы не будем осуществлять сборку , просто укажем папку с исходным кодом при сборке Nginx.
Конфигурирование и сборка nginx
Перейдем в папку:
cd nginx
Создадим файл
mcedit configure.sh
С содержимым:
./auto/configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--modules-path=/usr/lib/nginx/modules \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--builddir=nginx-astra-linux \
--with-select_module \
--with-poll_module \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-http_perl_module=dynamic \
--with-http_ssl_module \
--with-pcre \
--with-pcre-jit \
--with-openssl=./openssl-3.0.3
Сделаем его исполняемым:
chmod +x configure.sh
Запустим:
./configure.sh
Запустим сборку:
make
Если всё прошло успешно, увидим текст:
sed -e "s|%%PREFIX%%|/etc/nginx|" \
-e "s|%%PID_PATH%%|/var/run/nginx.pid|" \
-e "s|%%CONF_PATH%%|/etc/nginx/nginx.conf|" \
-e "s|%%ERROR_LOG_PATH%%|/var/log/nginx/error.log|" \
< docs/man/nginx.8 > nginx-astra-linux/nginx.8
make[1]: выход из каталога «/home/user/nginx»
Запустим установку:
sudo make install
Проверим версию:
sudo nginx -v
nginx version: nginx/1.20.2
Проверим конфигурацию сборки:
sudo nginx -V
nginx version: nginx/1.20.2
built by gcc 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)
built with OpenSSL 3.0.3 3 May 2022
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --builddir=nginx-astra-linux --with-select_module --with-poll_module --with-threads --with-file-aio --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_slice_module --with-http_stub_status_module --with-http_perl_module=dynamic --with-http_ssl_module --with-pcre --with-pcre-jit --with-openssl=~/openssl-3.0.3
Nginx c поддержкой openssl 3.0.3 установлен.
Запускаем nginx как службу
Создадим файл:
sudo mcedit /lib/systemd/system/nginx.service
С содержимым:
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Включим сервис:
sudo systemctl enable nginx
sudo systemctl daemon-reload
Запустим:
sudo systemctl start nginx
Откроем адрес виртуального сервера:
http://192.168.1.40/
Страница открывается
В заголовках страницы можно увидеть, что сервер отдает свою версию:
Server: nginx/1.20.2
Заключение
Сегодня мы рассмотрели сборку из исходного кода web-сервера nginx с поддержкой последней версии openssl 3.0.3.
Установили требуемые пакеты
Загрузили исходный код Nginx и Openssl.
Сконфигурировали и произвели сборку nginx
Установили web-сервер и проверили версию и его конфигурацию.
Запустили сервер как службу.
Проверили загрузку тестовой страницы.
Добавить комментарий