本人幫協會搭的論壇,一直是使用ssl訪問的,但是普通的https既慢又吃資源,而有個協議可以很方便的解決這個問題,那就是大Google發明的SPDY協議。所以,我也開始嘗試著給自己的論壇加上SPDY協議,WEB服務器本人選擇的是nginx,在過去,Nginx并沒有內置SPDY協議,需要打開的話還要下載開發版然后手動編譯,很不方便。喜聞樂見的是,最近Nginx發布了1.6穩定版,這個版本終于內置了SPDY的支持,也是我等廣大建站人員的福音啊,我也就迫不及待的給論壇加上了SPDY協議支持了。 首先明確打開SPDY協議的前提,以下三個缺一不可:
1.Openssl 1.0.1e 或更高版本
2.網站已經安裝了SSL證書
3.Nginx 1.6 stable 或者 1.5Development
首先檢查Openssl的版本
CentOS 6 可以使用以下命令
[root@do ~]# rpm -q openssl
openssl-1.0.1e-16.el6_5.14.i686
可以看到CentOS 6 內置的Openssl已經是滿足要求了,如果是CentOS5的話就需要手動升級了 Ubuntu , Debian 和其他發行版可以用以下命令檢查版本
[root@do ~]# openssl version
OpenSSL 1.0.1e-fips 11 Feb 2013
檢查 Nginx 的版本
使用以下命令檢查Nginx的版本
[root@do ~]# nginx -v
nginx version: nginx/1.6.0
用以下命令查看Nginx里是否包含了SPDY
[root@do ~]# nginx -V |grep spdy
nginx version: nginx/1.6.0
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --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-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-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tables'
如果看到–with-http_spdy_module 就說明是滿足要求的。 如果沒有滿足要求,請去 http://nginx.org/ 下載安裝1.6 stable
打開Nginx的SPDY支持
假設已經在Nginx上配置了SSL的支持,那么打開SPDY就會非常的簡單 把以下SSL的配置
listen [::]:443 ssl;
listen 443 ssl;
改成
listen [::]:443 ssl spdy;
listen 443 ssl spdy;
然后重啟Nginx服務 即可 大功告成