Как установить Nginx + OpenSSL 1.0.2h with APLN support на Centos 6.х для включения http2 протокола
Выполняем пошагово и собираем из исходников:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
yum install gc gcc gcc-c++ pcre-devel zlib-devel make wget openssl-devel libxml2-devel libxslt-devel gd-devel perl-ExtUtils-Embed GeoIP-devel gperftools gperftools-devel libatomic_ops-devel perl-ExtUtils-Embed -y export CFLAGS='-O -fPIC' export CC="gcc -fPIC" export CXX="g++ -fPIC" export CXXFLAGS="$CXXFLAGS -fPIC" cd /usr/local/src git clone https://github.com/openssl/openssl.git cd /usr/local/src/openssl ./config make depend make make test make install mv /usr/bin/openssl /usr/bin/openssl_1.0.1e ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl openssl version OpenSSL 1.0.2h 3 May 2016 |
Далее устанавливаем nginx из исходного кода на шаге ./configure вам нужно вставить свои параметры с команды nginx -V:
1 2 3 4 5 6 7 |
cd /usr/local/ wget http://nginx.org/download/nginx-1.13.5.tar.gz tar zxvf nginx-1.13.5.tar.gz cd nginx-1.13.5 ./configure --with-openssl=/usr/local/src/openssl а далее ваши опции, пример ниже make make install |
Мой пример результата команды nginx -V для сохранения опций и подставки в команду ./configure выше:
1 |
--prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' |
Эти опции прописываем в команде на шаге выше ./configure –with-openssl=/usr/local/src/openssl –enable-shared на шаге выше пере make.
После установки должно получиться следующее:
1 2 3 4 5 6 |
# nginx -V nginx version: nginx/1.13.5 built by gcc 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC) built with OpenSSL 1.0.2h 3 May 2016 TLS SNI support enabled configure arguments: --with-openssl=/usr/local/src/openssl --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-compat --with-file-aio --with-threads --with-http_addition_module --with-http_auth_request_module --with-http_dav_module --with-http_flv_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_mp4_module --with-http_random_index_module --with-http_realip_module --with-http_secure_link_module --with-http_slice_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-mail --with-mail_ssl_module --with-stream --with-stream_realip_module --with-stream_ssl_module --with-stream_ssl_preread_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fPIC' --with-ld-opt='-Wl,-z,relro -Wl,-z,now -pie' |
После этого меняйте в конфигах где используется 443 порт строку на следующую:
1 |
listen 192.168.1.1:443; |
на
1 |
listen 192.168.1.1:443 ssl http2; |
Для пользователей панели VestaCP
Можно отредактировать файлы:
1 2 3 4 5 6 7 |
/usr/local/vesta/data/templates/web/nginx/default.tpl /usr/local/vesta/data/templates/web/nginx/hosting.tpl /usr/local/vesta/data/templates/web/nginx/caching.tpl /usr/local/vesta/data/templates/web/nginx/default.stpl /usr/local/vesta/data/templates/web/nginx/hosting.stpl /usr/local/vesta/data/templates/web/nginx/caching.stpl |
И изменить в них строку:
1 |
listen %ip%:%proxy_ssl_port%; |
на
1 |
listen %ip%:%proxy_ssl_port% ssl http2; |
После чего делаем ребилд web-конфигов командой:
1 |
/usr/local/vesta/bin/v-rebuild-web-domains USER |
где USER логин вашего пользователя (по умолчанию admin).