【问题标题】:What website supports http/2 on port 80 with no SSL?哪个网站在没有 SSL 的情况下支持端口 80 上的 http/2?
【发布时间】:2016-09-17 00:07:27
【问题描述】:

我想在 http/2 上为端口 80 运行一个wireshark

1. be able to test out an http/2 client
2. follow a wireshark trace to understand the protocol better

有没有在 80 端口支持 http/2 的网站?当我去 google 时,它​​总是把我变成 https。

谢谢, 院长

【问题讨论】:

  • 清除网络浏览器缓存并转到https://www.google.com/。您还可以使用 Google Chrome/Internet Explorer 开发者工具的“网络”选项卡查看 HTTP/2 流量。您需要启用 SSL/TLS 的解密(参见 here 例如,搜索 SSLKEYLOGFILE)以检查 HTTP/2 流量。您将可以通过http2tcp.port == 443 进行过滤,但不能通过 80 后过滤。
  • 规范 tools.ietf.org/html/rfc7540 说端口 80 也支持 http/2,它只是在使用端口 80 时以 h2c 令牌而不是 h2 令牌开头。是否没有支持 http/2 的明文网站然而? (即。我必须采用 ssl 方式?)。也就是说,这个答案仍然很酷。 (你为什么不把它作为答案发布)
  • 一个可以实现h2c,但是大多数网络服务器只支持h2,并且只是将http的流量重定向到https。它更简单,现代 TLS 1.2 实现通常支持 ALPN 协议,这简化了 HTTP/2 的使用。在发送第一个 h2 数据包之前,请参阅典型 TLS 流量的 here 示例。

标签: http2


【解决方案1】:

Jetty 项目实现了一个 HTTP/2 服务器,它可以使用加密的 HTTP/2 和明文 HTTP/2。

您可以轻松地在本地设置 Jetty h2c 服务器,支持直接 HTTP/2 通信以及支持 HTTP/1.1 升级到 HTTP/2。

我建议你不要用你的实验轰炸公共服务器 :)

这是服务器代码:

public class H2C
{
    public static void main(String[] args) throws Exception
    {
        Server server = new Server();

        HttpConfiguration config = new HttpConfiguration();
        HttpConnectionFactory h1 = new HttpConnectionFactory(config);
        HTTP2CServerConnectionFactory h2 = new HTTP2CServerConnectionFactory(config);
        ServerConnector connector = new ServerConnector(server, h1, h2);
        connector.setPort(8080);
        server.addConnector(connector);

        server.setHandler(new AbstractHandler()
        {
            @Override
            protected void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
            {
                baseRequest.setHandled(true);
                // Your code here.
            }
        });

        server.start();
    }
}

您可以使用 HTTP/2 客户端测试服务器,例如nghttp,并通过 Wireshark 观察流量。

通过升级测试明文 HTTP/2(使用 -u 标志,-v 标志用于详细说明):

$ nghttp -uv http://localhost:8080/

[  0.000] Connected
[  0.000] HTTP Upgrade request
GET / HTTP/1.1
host: localhost:8080
connection: Upgrade, HTTP2-Settings
upgrade: h2c
http2-settings: AAMAAABkAAQAAP__
accept: */*
user-agent: nghttp2/1.7.1


[  0.001] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols


[  0.001] HTTP Upgrade success
[  0.001] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
      (dep_stream_id=0, weight=201, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
      (dep_stream_id=0, weight=101, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
      (dep_stream_id=0, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
      (dep_stream_id=7, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
      (dep_stream_id=3, weight=1, exclusive=0)
[  0.001] send PRIORITY frame <length=5, flags=0x00, stream_id=1>
      (dep_stream_id=11, weight=16, exclusive=0)
[  0.001] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.001] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.002] recv (stream_id=1) :status: 200
[  0.002] recv (stream_id=1) server: Jetty(9.4.z-SNAPSHOT)
[  0.002] recv (stream_id=1) date: Fri, 20 May 2016 09:38:52 GMT
[  0.002] recv HEADERS frame <length=45, flags=0x05, stream_id=1>
      ; END_STREAM | END_HEADERS
      (padlen=0)
      ; First response header
[  0.002] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
      (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])

或者直接测试明文HTTP/2:

$ nghttp -v http://localhost:8080/

[  0.000] Connected
[  0.000] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
      (dep_stream_id=0, weight=201, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
      (dep_stream_id=0, weight=101, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
      (dep_stream_id=0, weight=1, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
      (dep_stream_id=7, weight=1, exclusive=0)
[  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
      (dep_stream_id=3, weight=1, exclusive=0)
[  0.000] send HEADERS frame <length=38, flags=0x25, stream_id=13>
      ; END_STREAM | END_HEADERS | PRIORITY
      (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
      ; Open new stream
      :method: GET
      :path: /
      :scheme: http
      :authority: localhost:8080
      accept: */*
      accept-encoding: gzip, deflate
      user-agent: nghttp2/1.7.1
[  0.095] recv SETTINGS frame <length=12, flags=0x00, stream_id=0>
      (niv=2)
      [SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
      [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
[  0.095] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.096] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
      ; ACK
      (niv=0)
[  0.105] recv (stream_id=13) :status: 200
[  0.105] recv (stream_id=13) server: Jetty(9.4.z-SNAPSHOT)
[  0.105] recv (stream_id=13) date: Fri, 20 May 2016 09:39:30 GMT
[  0.105] recv HEADERS frame <length=45, flags=0x05, stream_id=13>
      ; END_STREAM | END_HEADERS
      (padlen=0)
      ; First response header
[  0.106] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
      (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])

【讨论】:

    猜你喜欢
    • 2020-08-30
    • 2020-06-27
    • 1970-01-01
    • 1970-01-01
    • 2014-07-13
    • 1970-01-01
    • 2015-11-14
    • 2020-09-20
    相关资源
    最近更新 更多