IIS 10 支持 HTTP/2,但如果网站配置为使用 Windows 身份验证,它会降级到 HTTP/1.1。
我想创建一个不需要域用户登录(Windows Auth 非常适合)但仍然能够使用 HTTP/2 的 Web 应用程序。您对如何设计有想法吗?
到目前为止我自己的想法:也许我可以将应用程序外部的 Windows Auth 放入另一个创建 JWT 的服务中,然后使用该 JWT 在主应用程序上进行身份验证。
但这增加了很多复杂性:
因此,对于它的价值来说,这可能是太多的努力。
你能想出更好的主意吗?
每隔几个请求就会发生这种奇怪的事情,Go 的http包会抛出以下错误:
http2: server sent GOAWAY and closed the connection; LastStreamID=19999, ErrCode=NO_ERROR, debug=""
Run Code Online (Sandbox Code Playgroud)
所以我意识到默认传输已ForceAttemptHTTP2设置为true(https://golang.org/src/net/http/transport.go第 48 行),所以我手动将其设置为 false ,如下所示:
transport := &http.Transport{
ForceAttemptHTTP2: false,
}
httpClient := &http.Client{Transport: transport}
Run Code Online (Sandbox Code Playgroud)
但即使这样做之后,我仍然得到相同的 http2 错误而不是 http1,这对我来说没有意义?
我是网络新手,所以我感觉我错过了一些在这里应该很明显的东西?
我想问题是如何强制该http包仅使用http而不使用http2
是否有工具可以查看HTTP 2.0的内容(原始请求和响应)?我使用了Fiddler,仅看到HTTP 1.1数据。
我在Chrome中启用了HTTP 2.0 / SPDY,并访问了https://http2.akamai.com以查看请求和响应。
大多数浏览器都支持HTTP/2,一些服务器也支持.
例如,Akamai提供HTTP/2测试页(https://http2.akamai.com/).当我在chrome中访问此页面并转到chrome://net-internals/#spdy该页面时,会列出协议h2-14(HTTP/2草案14).但是,当我打开Akamai的页面上的控制台,然后输入window.chrome.loadTimes()属性wasFetchedViaSpdy是true.为什么是这样?Akamai页面是HTTP/2,而不是SPDY,roght?
我得到的另一件事是本教程(https://www.gatherdigital.co.uk/blog/how-to-setup-http-2-support/527).它说:
"如何设置HTTP/2支持(nginx,apache,plesk)[...]嗯,不是HTTP/2,它仍然是mod_spdy."
什么是这个HTTP/2"over"SPDY的东西?我的问题的原因是我想对哪些页面使用哪种协议进行一些测量.
我yum install nginx在我的ECS服务器上使用过,但版本不够高,无法支持http2.谷歌搜索后,我添加了一个配置文件:
/etc/yum.repos.d/nginx.repo
Run Code Online (Sandbox Code Playgroud)
随着内容:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Run Code Online (Sandbox Code Playgroud)
然后我运行yum update nginx,它给了我1.8.1版本,它仍然不够高,不支持http2.
任何人都可以帮助我将我的nginx更新到1.9.5或更高版本吗?
有没有办法强制PHP与另一台服务器建立HTTP2连接只是为了查看该服务器是否支持它?
我试过了:
$options = stream_context_create(array(
'http' => array(
'method' => 'GET',
'timeout' => 5,
'protocol_version' => 1.1
)
));
$res = file_get_contents($url, false, $options);
var_dump($http_response_header);
Run Code Online (Sandbox Code Playgroud)
并试过:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTP_VERSION, 3);
$response = curl_exec($ch);
var_dump($response);
curl_close($ch);
Run Code Online (Sandbox Code Playgroud)
但是如果我使用以下URL,两种方式都会给我一个HTTP1.1响应 https://www.google.com/#q=apache+2.5+http%2F2
我正在从启用HTTP/2 + SSL的域发送请求.我究竟做错了什么?
根据这个https://curl.haxx.se/docs/http2.html
Since 7.47.0, the curl tool enables HTTP/2 by default for HTTPS connections.
使用自制软件安装最新版本并检查:
curl --version
curl 7.54.1 (x86_64-apple-darwin15.6.0) libcurl/7.54.1 SecureTransport zlib/1.2.5
Run Code Online (Sandbox Code Playgroud)
但curl在启用HTTP2的URL上运行(例如使用https://tools.keycdn.com/http2-test测试)我得到:
curl -I http://www.google.co.uk
HTTP/1.1 200 OK
Run Code Online (Sandbox Code Playgroud)
和
curl --http2 -v http://www.google.co.uk
curl: (1) Unsupported protocol
Run Code Online (Sandbox Code Playgroud)
知道为什么它使用HTTP/1.1而不是HTTP/2?
我已按照以下链接启用centos-7 apache中的http/2. https://www.tunetheweb.com/performance/http2/
我的openssl版本:
# openssl version
OpenSSL 1.1.0f 25 May 2017
Run Code Online (Sandbox Code Playgroud)
在安装最新的apr-util和apache(httpd-2.4.27)时,make命令会发生错误
在apr-util文件夹中:
# make
make[1]: Entering directory `/usr/local/src/apr-util-1.6.0'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/usr/local/src/apr-util-1.6.0/incl
ude -I/usr/local/src/apr-util-1.6.0/include/private -I/usr/local/apr/include/apr-1 -o xml/apr_xml.lo -c xml/apr_xml.c && touch xml/apr_xml.lo
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
#include <expat.h>
^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/usr/local/src/apr-util-1.6.0'
make: *** [all-recursive] Error 1
Run Code Online (Sandbox Code Playgroud)
在httpd文件夹中:
#make
Making all in srclib
make[1]: …Run Code Online (Sandbox Code Playgroud) 我目前正在使用SwiftNIO和SwiftNIOHTTP2 beta在Swift中使用简单的HTTP2客户端.我的实现看起来像这样:
let group = MultiThreadedEventLoopGroup(numberOfThreads: 1)
let bootstrap = ClientBootstrap(group: group)
.channelOption(ChannelOptions.socket(SocketOptionLevel(SOL_SOCKET), SO_REUSEADDR), value: 1)
.channelInitializer { channel in
channel.pipeline.add(handler: HTTP2Parser(mode: .client)).then {
let multiplexer = HTTP2StreamMultiplexer { (channel, streamID) -> EventLoopFuture<Void> in
return channel.pipeline.add(handler: HTTP2ToHTTP1ClientCodec(streamID: streamID, httpProtocol: .https))
}
return channel.pipeline.add(handler: multiplexer)
}
}
defer {
try! group.syncShutdownGracefully()
}
let url = URL(string: "https://strnmn.me")!
_ = try bootstrap.connect(host: url.host!, port: url.port ?? 443)
.wait()
Run Code Online (Sandbox Code Playgroud)
不幸的是,连接始终失败并出现错误:
nghttp2错误:当我们期望SETTINGS帧时,远程对等体返回了意外数据.也许,peer不能正确支持HTTP/2.
但是,从命令行使用nghttp2连接和发出一个简单的请求可以正常工作.
$ nghttp -vn https://strnmn.me
[ 0.048] Connected
The negotiated protocol: h2 …Run Code Online (Sandbox Code Playgroud)