Last Updated on 1월 4, 2021 by 태랑(정현호)
Nginx - HTTP/2 와 TLS v1.3
Nginx 에서 HTTP/2 적용 과 HTTPS TLS v1.3 를 사용하기 위해서는 일정 이상의 버전이 필요합니다.
HTTP/2 : nginx 1.9.5 이상 , OpenSSL 1.0.2
HTTPS TLS v1.3 : nginx 1.13.0 이상, OpenSSL 1.1.1
하지만 CentOS 7.8 버전에서 yum(패키지)로 설치 가능한 버전은 아래와 같이 1.19.4 with OpenSSL 1.0.2k 입니다
[root]# nginx -V
nginx version: nginx/1.19.4
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
[root]# openssl version
OpenSSL 1.0.2k-fips 26 Jan 2017
버전은 충족하지만 Build 시 Include 된 OpenSSL 의 버전이 낮음으로 Nginx를 Source Compile 하거나 Source RPM(SRPM) 으로 컴파일이 필요 합니다.
* 이전 글에서 포크된 글 입니다.

Nginx Repository
먼저 Nginx Repository를 설정 하겠습니다
* 이전 포스팅을 통해 Repository를 설정하였다면 이 과정은 생략 합니다.
Nginx 는 Mainline 버전과 Stable 버전이 있습니다.
새로운 특징, 기능, 버그 패치 등은 Mainline 버전에서 작업하고 그 이후에, 새로운 기능이 추가되지 않고 버그 패치만 하는 게 Stable 버전입니다.
버전 선택에 관련해서 NGINX 의 공식 입장은 다음과 같습니다.
We recommend that in general you deploy the NGINX mainline branch at all times.
The main reason to use the stable branch is that you are concerned about possible impacts of new features,
such as incompatibility with third-party modules or the inadvertent introduction of bugs in new features.
기본적으로 Mainline 버전을 택하고 지속적으로 업데이트 하기를 권장하고 있습니다.
Stable 버전은 3rd party(서드 파티) 모듈과 호환성 문제 또는 New Feature 로 인한 문제로 인하여 업데이트가 불가능한 상황에서 사용하면 된다고 합니다.
버전은 환경을 고려하여 선택하시면 될 것 같습니다
* 여기 에서는 Mainline 버전으로 하여 최신버전을 설치 하도록 하겠습니다.
* 설치의 진행은 root로 하였습니다
# 필요 패키지 설치하기
[root]# yum install -y yum-utils curl gnupg2
# Nginx Repository 생성
[root]# vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
위의 내용으로 nginx.repo 생성시 stable 버전이 설치되는 것이 Default 입니다.
여기 포스팅에서는 mainline nginx packages 를 사용 할 것임으로 mainline repository를 활성화 하도록 하겠습니다.
[root]# yum-config-manager --enable nginx-mainline
사전 패키지 설치 및 파일 다운 로드
필요 패키지 설치
[root]# yum -y install wget gcc gcc-c++ make \
openssl-devel libxml2-devel libxslt-devel \
gd-devel perl-ExtUtils-Embed GeoIP-devel \
pcre-devel rpm-build
Create a user to perform the builds.
[root]# groupadd builder
[root]# useradd -g builder builder
Openssl 1.1.1 버전 다운로드
[root]# wget https://www.openssl.org/source/openssl-1.1.1h.tar.gz
[root]# tar zxvf openssl-1.1.1h.tar.gz -C /usr/local/src/
Openssl 1.1.1 빌드 및 설치
[root]# cd /usr/local/src/openssl-1.1.1h
[root]# ./config --prefix=/usr/local/openssl-1.1.1h
[root]# make;make install
/etc/ld.so.conf 에 아래 내용 추가
[root]# vi /etc/ld.so.conf
/usr/local/openssl-1.1.1h/lib
[root]# ldconfig
<-- 내용 추가 후 ldconfig 명령어 실행
버전 확인 및 경로 변경
[root]# /usr/local/openssl-1.1.1h/bin/openssl version
OpenSSL 1.1.1h 22 Sep 2020
[root]# mv /bin/openssl /bin/openssl.1.0.2k-fips
<-- 기존 버전 rename 하여 백업을 합니다.
[root]# ln -s /usr/local/openssl-1.1.1h/bin/openssl /bin/openssl
<-- 심볼링크 생성
Nginx SRPM 설치
[root]# rpm -ivh http://nginx.org/packages/mainline/centos/7/SRPMS/nginx-1.19.6-1.el7.ngx.src.rpm
Config&Build
Configuration
[root]# sed -i "s|--with-http_ssl_module|--with-http_ssl_module \
--with-openssl=/usr/local/src/openssl-1.1.1h \
--with-openssl-opt=enable-tls1_3 |g" \
/root/rpmbuild/SPECS/nginx.spec
Build
[root]# rpmbuild -ba /root/rpmbuild/SPECS/nginx.spec
Build 된 패키지 설치
[root]# cd /root/rpmbuild/RPMS/x86_64/
[root]# rpm -ivh nginx-1.19.6-1.el7.ngx.x86_64.rpm
버전 확인
[root]# nginx -V
nginx version: nginx/1.19.6
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1h 22 Sep 2020
TLS SNI support enabled
이어지는 글

연관된 다른 글
- CentOS 에 Apache PHP Mysql 연동 설치 포스팅

- 우분투 환경에서 Apache PHP Mysql 연동 설치 포스팅

- 우분투 환경에서 Nginx PHP MariaDB 연동 설치 포스팅

- Nginx 에 ModSecurity 설치 - Nginx 웹 방화벽 / WAF

- CentOS 8 버전 지원 종료 및 정책 변경 안내 - Rocky Linux 소개

- CentOS 8 환경에서 Nginx + PHP-FPM + MariaDB 구성

Senior DBA(Mysql, Oracle) - 현재 위메프에서 많은 새로움을 경험중입니다
At WeMakePrice / Previous - Oracle Korea ACS Support / Fedora Kor UserGroup 운영중
Database 외에도 NoSQL , Linux , Cloud, Http/PHP CGI 등에도 관심이 있습니다
purityboy83@gmail.com / admin@hoing.io