digital oceanにspdy付きのnginx構築する
経緯
- spdyをちょっと試してみたい。
- digital ocean使って、spdy付きのnginx構築してみた。
- これは、そのメモ。
前提
nginxインストール
yum install wget gcc pcre-devel gd-devel perl cd /usr/local/src/ wget http://www.openssl.org/source/openssl-1.0.1h.tar.gz tar zxvf openssl-1.0.1h.tar.gz wget http://nginx.org/download/nginx-1.7.3.tar.gz tar zxvf nginx-1.7.3.tar.gz cd nginx-1.7.3 ./configure --with-http_ssl_module --with-http_spdy_module --with-openssl=../openssl-1.0.1h make make install
ssl証明書の作成
$ cd $HOME $ openssl genrsa -des3 -out certificate.key 2048 $ openssl req -new -key certificate.key -out certificate.csr $ cp certificate.key certificate.key.org $ openssl rsa -in certificate.key.org -out certificate.key $ openssl x509 -req -days 3650 -in certificate.csr -signkey certificate.key -out certificate.crt $ sudo mv certificate.* /usr/local/nginx/conf
nginxでspdy有効にする
vi /usr/local/nginx/conf/nginx.conf
- sslの設定のコメントを外して、幾つか追加変更する
# HTTPS server # server { listen 443 default ssl spdy; //★ここを追加 server_name _; //★ここも一応変えておいた ssl_certificate /usr/local/nginx/conf/certificate.crt; ssl_certificate_key /usr/local/nginx/conf/certificate.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } }
spdy indicatorを入れる
- spdy indicatorというchrome extension入れる
nginx起動して確認してみる
- nginx起動
/usr/local/nginx/sbin/nginx
参考
- hatyuki氏のブログ
- 基本的にこれをベースにversion等新しくした
- 公式からリンクあるspdy記事
install中のエラー
エラーでまくって、困ってる人のためにも残しておく
configureでのエラー
- 初めに、pcre-develとgd-devel(zlib)入れないとこんなエラーでる
./configure: error: the HTTP rewrite module requires the PCRE library.
./configure: error: the HTTP gzip module requires the zlib library.
makeでのエラー
- install時にwith-http_ssl_moduleオプション入れないとこんなエラーがでる
make: *** `default' に必要なターゲット `build' を make するルールがありません. 中止.
- perl入れてないと、makeでこんなエラー出る
You need Perl 5. make[1]: *** [../openssl-1.0.1h/.openssl/include/openssl/ssl.h] エラー 1 make[1]: ディレクトリ `/usr/local/src/nginx-1.7.3' から出ます make: *** [build] エラー 2