如何通过Nginx设置SPDY协议? [英] How to set up SPDY Protocol over Nginx?

查看:96
本文介绍了如何通过Nginx设置SPDY协议?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Rails应用,想要设置Google SPDY协议支持.但是在安装带有SPDY补丁的Nginx并在虚拟主机中启用spdy之后,它不允许我重新启动nginx而是抛出以下错误.

I have a rails app and want to set up the google SPDY protocol support. But after installing Nginx with SPDY patch and then enabling the spdy in virtual host it does not allow me to restart the nginx instead throws following error.

Restarting nginx: nginx: [emerg] invalid parameter "spdy" in /etc/nginx/sites-enabled/default:112
nginx: configuration file /etc/nginx/nginx.conf test failed

我已经用spdy补丁编译了最新的nginx 1.3.13,在这里我要提到我的安装步骤

I have compiled latest nginx 1.3.13 with spdy patch, here I am mentioning my steps of install

wget http://nginx.org/download/nginx-1.3.13.tar.gz
tar xvfz nginx-1.3.13.tar.gz
cd nginx-1.3.13

# Fetch the SPDY patch and apply it
wget http://nginx.org/patches/spdy/patch.spdy.txt
patch -p1 < patch.spdy.txt

 ./configure \
 --sbin-path=/usr/local/sbin/nginx \
 --prefix=/etc/nginx \
 --conf-path=/etc/nginx/nginx.conf \
 --error-log-path=/var/log/nginx/error.log \
 --http-client-body-temp-path=/var/lib/nginx/body \
 --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
 --http-log-path=/var/log/nginx/access.log \
 --http-proxy-temp-path=/var/lib/nginx/proxy \
 --http-scgi-temp-path=/var/lib/nginx/scgi \
 --http-uwsgi-temp-path=/var/lib/nginx/uwsgi \
 --lock-path=/var/lock/nginx.lock \
 --pid-path=/var/run/nginx.pid \
 --with-debug \
 --with-http_addition_module \
 --with-http_dav_module \
 --with-http_gzip_static_module \
 --with-http_realip_module \
 --with-http_stub_status_module \
 --with-http_ssl_module \
 --with-http_sub_module \
 --with-http_xslt_module \
 --with-http_spdy_module \
 --with-ipv6 \
 --with-sha1=/usr/include/openssl \
 --with-md5=/usr/include/openssl \
 --with-mail \
 --with-mail_ssl_module \

 # wget https://you.googlecode.com/files/ngx_cache_purge-1.6.tar.gz
 --add-module=/software/ngx_cache_purge-1.6 \

 #http://www.openssl.org/source/openssl-1.0.1e.tar.gz
 --with-openssl='/software/openssl-1.0.1e' 

 # Build and install nginx
 make && sudo make install

它编译成功,没有任何错误. 结果0f nginx -V给出以下内容

It compiles successfully without any error. Result 0f nginx -V gives following

nginx version: nginx/1.3.13
built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) 
TLS SNI support enabled
configure arguments: --sbin-path=/usr/local/sbin/nginx --prefix=/etc/nginx --conf-           path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_addition_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-http_spdy_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/software/ngx_cache_purge-1.6 --with-openssl=/software/openssl-1.0.1e

我的/etc/nginx/启用站点的配置具有

My /etc/nginx/site-enabled config has

server {
      listen 443 ssl spdy;

      ssl_certificate      server.crt;
      ssl_certificate_key  server.key;  

      ...
  }

在成功完成所有这些安装之后,nginx不会在启用站点的文件的服务器块中以spdy param重新启动.

After all this successfull installation nginx does not restart with spdy param in server block of site-enabled file.

有什么建议吗?我肯定会在这里遗漏一些东西,但无法弄清楚.

Any suggestions? I am sure of missing something here but can't figure out.

推荐答案

更新(2013年11月19日):修改了nginx 1.4.3的脚本(不需要spdy补丁)

UPDATE (November 19th, 2013): Modified script for nginx 1.4.3 (Does not need spdy patch)

https://gist.github.com/deepak-kumar /7541199#file-compile_nginx_1-4-3_with-spdy-sh

我为该设置编写了Shell脚本

I wrote Shell Script for the setup

https://gist.github.com/deepak-kumar/5069550#file-compile_nginx_with_spdy -sh

我找到了解决问题的方法.

I have found the solution to the problem.

即使在编译导致问题的1.3.13之前,我已经在ubuntu 12.04上安装了nginx软件包.$ sudo apt-get install nginx

I already had nginx package installed on my ubuntu 12.04 even before compiling this 1.3.13 which was causing the problem.$ sudo apt-get install nginx

要解决此问题,我确保/etc/init.d/nginx应该使用正确的二进制文件.

To solve this issue I made sure that /etc/init.d/nginx should use the correct binary.

我在终端上做了以下事情:

I did following on terminal:

$ which nginx
$ /usr/local/sbin/nginx

检查我现有的/etc/init.d/nginx脚本是否使用了错误的DAEMON路径,因此我将其更改为如下所示(有效)

Checked my existing /etc/init.d/nginx script it was using wrong DAEMON path so I changed it to look like this (works)

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/nginx # $which nginx

之前的值是(不起作用)

Earlier above values were (does not work)

#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
#DAEMON=/usr/sbin/nginx

文件的其余部分保持不变.因此,基本上我使用了正确的二进制版本.

Rest of the file remains same. So essentially I used the correct version binary.

更新:如果您对此感兴趣的话,此博客也是一个很好的参考点. http://blog.bubbleideas.com/2012/08/How-to-set-up-SPDY-on-nginx-for-your-rails-app-and-test-it.html

Update: This blog is also a very good reference point in case you guys are interested. http://blog.bubbleideas.com/2012/08/How-to-set-up-SPDY-on-nginx-for-your-rails-app-and-test-it.html

这篇关于如何通过Nginx设置SPDY协议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆