标签: http2

如何在 HTTP/2 Web 应用程序中使用 Windows 身份验证(在 IIS 上)

IIS 10 支持 HTTP/2,但如果网站配置为使用 Windows 身份验证,它会降级到 HTTP/1.1。

我想创建一个不需要域用户登录(Windows Auth 非常适合)但仍然能够使用 HTTP/2 的 Web 应用程序。您对如何设计有想法吗?

到目前为止我自己的想法:也许我可以将应用程序外部的 Windows Auth 放入另一个创建 JWT 的服务中,然后使用该 JWT 在主应用程序上进行身份验证。

但这增加了很多复杂性:

  • Chrome 目前不会在同一域中混合 HTTP/2 和 HTTP/1.1(FF 会),因此该服务必须位于不同的域中,这意味着需要额外的 SSL 证书 + DNS 配置等。
  • 我需要在对服务器的任何调用期间处理 JWT 过期问题。

因此,对于它的价值来说,这可能是太多的努力。

你能想出更好的主意吗?

iis windows-authentication http2

5
推荐指数
1
解决办法
3263
查看次数

即使强制尝试设置为 false,Go http 请求也会回退到 http2

每隔几个请求就会发生这种奇怪的事情,Go 的http包会抛出以下错误:

http2: server sent GOAWAY and closed the connection; LastStreamID=19999, ErrCode=NO_ERROR, debug=""
Run Code Online (Sandbox Code Playgroud)

所以我意识到默认传输已ForceAttemptHTTP2设置为truehttps://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 go http2

5
推荐指数
1
解决办法
3666
查看次数

线上HTTP 2.0(原始)

是否有工具可以查看HTTP 2.0的内容(原始请求和响应)?我使用了Fiddler,仅看到HTTP 1.1数据。

我在Chrome中启用了HTTP 2.0 / SPDY,并访问了https://http2.akamai.com以查看请求和响应。

fiddler wireshark http2

4
推荐指数
1
解决办法
2805
查看次数

没有SPDY的HTTP/2可能吗?

大多数浏览器都支持HTTP/2,一些服务器也支持.

例如,Akamai提供HTTP/2测试页(https://http2.akamai.com/).当我在chrome中访问此页面并转到chrome://net-internals/#spdy该页面时,会列出协议h2-14(HTTP/2草案14).但是,当我打开Akamai的页面上的控制台,然后输入window.chrome.loadTimes()属性wasFetchedViaSpdytrue.为什么是这样?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的东西?我的问题的原因是我想对哪些页面使用哪种协议进行一些测量.

spdy http2 mod-spdy

4
推荐指数
1
解决办法
687
查看次数

如何在CentOS 7上用yum更新我的Nginx

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或更高版本吗?

nginx yum http2

4
推荐指数
1
解决办法
6290
查看次数

使用PHP发出HTTP/2请求

有没有办法强制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的域发送请求.我究竟做错了什么?

php curl http2

4
推荐指数
1
解决办法
7048
查看次数

为什么curl在mac上使用HTTP/1.1而不是HTTP/2?

根据这个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?

curl http-1.1 http2

4
推荐指数
1
解决办法
4096
查看次数

如何在centos 7中启用apache-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)

linux apache http2

4
推荐指数
1
解决办法
4111
查看次数

使用SwiftNIO和SwiftNIOHTTP2作为HTTP2客户端

我目前正在使用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)

http2 swift nghttp2 swift-nio

4
推荐指数
1
解决办法
651
查看次数

ServiceWorker提供的请求从HTTP / 2降级为HTTP / 1.1

我发现服务工作者存在一个奇特的问题,即使HTTP服务器通过HTTP / 2进行服务,它也显然将通过工作者提供的网络请求降级为HTTP / 1.1。我在ServiceWorkers在H2上服务的所有站点上都发现了这一点。

我在我的网站上找到了它,我认为这是GatsbyJS的问题。显然已经存在一个问题,表明Chromium中存在错误。

这是预期的行为吗?这种情况在哪里?

这是我网站的链接

http2 service-worker

4
推荐指数
1
解决办法
678
查看次数