VPS侦探论坛

 找回密码
 注册
查看: 9817|回复: 23

lnmp 1.3 可https访问,但无法开启http/2

[复制链接]
发表于 2016-3-4 01:01:16 | 显示全部楼层 |阅读模式

nginx升级到1.9.12,OpenSSL也升级到1.0.2g,使用的letsencrypt证书,nginx配置如下
server
{
listen 80;
listen 443 default_server ssl http2;
server_name www.17huiwei.com 17huiwei.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/www.17huiwei.com;

if ($scheme = http) {
    return 301 https://www.17huiwei.com$request_uri;
}

ssl_certificate /etc/letsencrypt/live/www.17huiwei.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.17huiwei.com/privkey.pem;

ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256HE-RSA-AES256-GCM-SHA384HE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHAHE-RSA-AES256-SHA256HE-RSA-AES128-SHA256HE-RSA-AES256-SHAHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHAES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:TLS:10m;
ssl_session_timeout 10m;
ssl_stapling on;
ssl_trusted_certificate /etc/letsencrypt/live/www.17huiwei.com/chain.pem;
ssl_dhparam /etc/ssl/certs/dhparam.pem;

include wordpress.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}

location ~ .*\.(js|css)?$
{
expires 24h;
}

access_log off;
}
include vhost/*.conf;
}

[[i] 本帖最后由 loren 于 2016-3-8 16:22 编辑 [/i]]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-3-4 09:12:13 | 显示全部楼层


chrome://net-internals/#http2 查看

www.17huiwei.com:443         direct://        2769        h2       

是支持的
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2016-3-5 20:41:44 | 显示全部楼层

还是不行,我看不到~~~是不是CHROME版本的问题?

我装了CHROME的SPDY/HTTPS插件,看GOOGLE、QQ邮箱等,都有HTTP/2标志,但是我的看不到。

是要用nginx+apache才能看到,纯nginx看不到?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-3-5 21:52:17 | 显示全部楼层

回复 3# 的帖子




这个不清楚,不需要使用插件就能查看,chrome原生就支持,2楼上我就发了查看方法

我们这边测试的情况只测试过lnmp下,是支持的,lnmpa没测试过
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2016-3-6 10:13:21 | 显示全部楼层

和我精简了CENTOS的一些小组件有没有关系?

yum remove Deployment_Guide-en-US finger cups-libs cups ypbind
yum remove bluez-libs desktop-file-utils ppp rp-pppoe wireless-tools irda-utils
yum remove sendmail* samba* talk-server finger-server bind* xinetd
yum update
yum clean all

军哥运维代购:http://shop63846532.taobao.com/

发表于 2016-3-6 16:30:00 | 显示全部楼层

回复 5# 的帖子


没关系,如果依赖包不够,nginx都不会安装上

2楼上我就已经说了,在我这边的chrome上看http2已经启用了
 楼主| 发表于 2016-3-6 17:47:28 | 显示全部楼层

遇到一个特别奇怪的事情,使用qq浏览器的极速模式可以看到HTTP/2进程,但是CHROME浏览器看不到~~~
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-3-6 19:48:06 | 显示全部楼层

回复 7# 的帖子


我的是原版chrome 48

网上也有专门的http2的测试站来测试是否支持http2:https://tools.keycdn.com/http2-test
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2016-3-6 22:04:33 | 显示全部楼层

Yeah! www.17huiwei.com supports HTTP/2.0.
ALPN is not supported.

上面支持,下面的ALPN是什么东西?没有查到
nginx 官方查到了 http://nginx.org/en/docs/http/ngx_http_v2_module.html

其中有一段 Note that accepting HTTP/2 connections over TLS requires the “Application-Layer Protocol Negotiation” (ALPN) TLS extension support, which is available only since OpenSSL version 1.0.2. Using the “Next Protocol Negotiation” (NPN) TLS extension for this purpose (available since OpenSSL version 1.0.1) is not guaranteed.


好像要1.0.2的OPENSSL才能支持。我升级一下试试看

=======================
估计是升级的办法不对,我用 https://yusky.me/centos-openssl-updateed-1-0-1g.html 这种办法升级,通过openssl version -a查询,版本号是1.0.2了,但是还是显示ALPN is not supported


建议军哥在lnmp 1.3 beta的改进版里面把OPENSSL也升级了

=======================

再次更新nginx,想重新编译openssl,结果挂了……
另外,找到一篇文章  https://www.xdty.org/1896  作者下面有回复
編譯的系統上裝的openssl 必須是1.0.2以上版本, 否則編譯出來的nginx 不支持 ALPN, 在某些瀏覽器上無法以http2 運作的

https://www.nginx.com/blog/http2-module-nginx/ 这里也有一段说明


It’s actually very simple. All you need to do is just add the HTTP/2 parameter to the listen directive. Probably the most complicated step here is to get the latest version of OpenSSL because HTTP/2 requires the ALPN extension, and the ALPN extension is only supported by OpenSSL 1.0.2.

[ 本帖最后由 loren 于 2016-3-6 22:52 编辑 ]
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-3-7 10:00:10 | 显示全部楼层

回复 9# 的帖子




openssl只会跟随系统,不会进行单独编译

要支持alpn可能nginx还需要重新编译并指定上你支持alpn的openssl的源码路径
 楼主| 发表于 2016-3-7 10:22:26 | 显示全部楼层

我是菜鸟,如果军哥不能更新lnmp1.3,能给想用http/2的菜鸟们提供一套官方的方法么?
发表于 2016-3-7 14:31:35 | 显示全部楼层

回复 11# 的帖子


http2早就支持了,10楼说的是不会真的alpn做单独的设置,http2看更新日志上有说明:http://lnmp.org/changelog.html 只要nginx1.9.5以上版本默认支持http2,用的时候在开启就行了

alpn的支持方法10楼也说了,你可以试试看,我们没有针对alpn进行测试
编译时指定上 --with-openssl=openssl源码目录全路径
lnmp 1.3可以直接修改lnmp.conf 里的Nginx_Modules_Options='' ,引号中加上--with-openssl=openssl源码目录全路径 ,然后重新升级一下nginx就行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2016-3-8 04:28:56 | 显示全部楼层
我也想用lnmp1.1,HTTP/2官方的方法
谢谢军哥
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2016-3-8 08:32:37 | 显示全部楼层

回复 13# 的帖子

lnmp 1.3之前的版本也可以直接使用lnmp 1.3版本里的升级工具进行升级,是兼容的

军哥运维代购:http://shop63846532.taobao.com/

发表于 2016-3-8 10:17:13 | 显示全部楼层
原帖由 loren 于 2016-3-4 01:01 发表
nginx升级到1.9.12,OpenSSL也升级到1.0.2g,使用的letsencrypt证书,nginx配置如下
server
{
listen 80;
listen 443 default_server ssl http2;
server_name www.17huiwei.com 17huiwei.com;
index index.html index.htm  ...

你可以同时开listen 80 与listen 443  难道不会冲突么?
SSL的据我所知是443  如果把http切换到https 难道不是只开启443么
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-28 23:30 , Processed in 0.033454 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表