banner
李大仁博客

李大仁博客

天地虽大,但有一念向善,心存良知,虽凡夫俗子,皆可为圣贤。

NginxはOpenSSLをLibreSSLに置き換えます。

先科普 LibreSSL は OpenSSL 暗号化ソフトウェアライブラリの派生です。セキュアソケットレイヤー(SSL)およびトランスポートレイヤーセキュリティ(TLS)プロトコルのオープンソース実装です。OpenSSL のハートブリードセキュリティ脆弱性が公表された後、一部の OpenBSD 開発者は 2014 年 4 月に LibreSSL を設立し、より安全な代替品を提供するために OpenSSL のコードを再構築することを目指しました。LibreSSL は OpenSSL ライブラリの 1.0.1g ブランチを複製しており、他の OpenBSD プロジェクトで使用されているセキュリティガイドラインに従います。

LibreSSL の利点と欠点を簡単にまとめると、利点は OpenSSL との互換性、コードのシンプルさ、明確な派生元、簡単なインストール、使用、およびメンテナンスが挙げられます。欠点は古いセキュリティアルゴリズムのサポートがなく、一部の暗号化アルゴリズムの効率が低いことです。

コンパイル環境をインストールする

#コンパイル環境をインストールする
yum install -y gcc gcc-c++ pcre-devel openssl openssl-devel

作業ディレクトリを作成し、絶対パスを使用する

#作業ディレクトリを作成し、絶対パスを使用する
mkdir /work
cd /work

LibreSSL のソースコードをダウンロードする

cd /work
wget http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.4.2.tar.gz
tar xvzf libressl-2.4.2.tar.gz

Nginx のソースコードをダウンロードする

cd /work
wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar -xzvf nginx-1.10.1.tar.gz
cd nginx-1.10.1

コンパイルオプションを設定し、openssl を libressl に置き換える "--with-openssl=/work/libressl-2.4.2"

./configure --with-openssl=/work/libressl-2.4.2/ \
--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-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--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_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_v2_module

Nginx + Libressl をコンパイルしてインストールする

#コンパイルしてインストールする
make;make install
#シンボリックリンクを作成する
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
ln -s /usr/local/nginx/conf /etc/nginx

Nginx + Libressl のコンパイルとインストールのテスト

#テスト
nginx -V

出力結果

nginx version: nginx/1.10.1 (Ubuntu)
built by gcc 4.9.2 20150212 (Red Hat 4.9.2-6)
built with LibreSSL 2.4.2
TLS SNI support enabled

完全な Nginx + Libressl のコンパイルとインストールスクリプト

#コンパイル環境をインストールする
yum install -y gcc gcc-c++ pcre-devel openssl openssl-devel
#作業ディレクトリを作成し、絶対パスを使用する
mkdir /work;cd /work

#LibreSSL のソースコードをダウンロードする
wget http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.4.2.tar.gz
tar xvzf libressl-2.4.2.tar.gz

#Nginx のソースコードをダウンロードする
cd /work
wget http://nginx.org/download/nginx-1.10.1.tar.gz
tar -xzvf nginx-1.10.1.tar.gz
cd nginx-1.10.1

#コンパイルオプションを設定する
./configure --with-openssl=/work/libressl-2.4.2/ \
--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-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--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_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-http_slice_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_v2_module

#コンパイルしてインストールする
make;make install
#シンボリックリンクを作成する
ln -s /usr/local/nginx/sbin/nginx /usr/sbin/nginx
ln -s /usr/local/nginx/conf /etc/nginx

#テスト
nginx -V

参考 http://www.oschina.net/translate/nginx-libressl-first-test?cmp https://community.centminmod.com/threads/libressl-2-4-2-released.8195/

読み込み中...
文章は、創作者によって署名され、ブロックチェーンに安全に保存されています。