如何通过 Nginx 设置 SPDY 协议?

2023-12-29

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

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,这里我提到我的安装步骤

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 给出以下结果

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/site-enabled 配置有

server {
      listen 443 ssl spdy;

      ssl_certificate      server.crt;
      ssl_certificate_key  server.key;  

      ...
  }

在所有这些成功安装之后,nginx 不会在启用站点的文件的服务器块中使用 spdy 参数重新启动。

有什么建议么?我确信这里遗漏了一些东西,但无法弄清楚。


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

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

我为设置编写了 Shell 脚本

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

我已经找到了问题的解决方案。

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

为了解决这个问题,我确保 /etc/init.d/nginx 应使用正确的二进制文件。

我在终端上做了以下操作:

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

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

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

之前的上述值是(不起作用)

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

文件的其余部分保持不变。所以基本上我使用了正确版本的二进制文件。

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何通过 Nginx 设置 SPDY 协议? 的相关文章

随机推荐